Zelda Classic Coverage Report


Directory: src/
File: src/zc/script_drawing.cpp
Date: 2023-03-18 18:24:01
Exec Total Coverage
Lines: 1264 5109 24.7%
Functions: 46 103 44.7%
Branches: 548 2629 20.8%

Line Branch Exec Source
1 // This program is free software; you can redistribute it and/or modify it under the terms of the
2 // modified version 3 of the GNU General Public License. See License.txt for details.
3
4 //! ritate_sprite_trans doesn't seem to be supported by or allegro header !?
5
6 //glibc 2.28 and later require this: -Z
7 #ifdef __GNUG__
8 #define ALLEGRO_NO_FIX_ALIASES
9 #endif
10
11 #define LOG_BMPBLIT_LEVEL 0
12 #include "precompiled.h" //always first
13
14 #include "base/allegro_wrapper.h"
15 #include "script_drawing.h"
16 #include "rendertarget.h"
17
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 #include "maps.h"
18 #include "tiles.h"
19 #include "zelda.h"
20 #include "ffscript.h"
21 #include "base/util.h"
22 #include "subscr.h"
23 #include "drawing.h"
24 using namespace util;
25 extern FFScript FFCore;
26 extern ZModule zcm;
27 extern refInfo *ri;
28 extern script_bitmaps scb;
29 #include <stdio.h>
30 #include <fstream>
31
32 #define DegtoFix(d) ((d)*0.7111111111111)
33 #define RadtoFix(d) ((d)*40.743665431525)
34
35 inline double sd_log2( double n )
36 {
37 // log(n)/log(2) is log2.
38 double v = log( (double)n ) / log( (double)2 );
39 return v;
40 }
41
42 inline bool isPowerOfTwo(int32_t n)
43 {
44 if(n==0)
45 return false;
46
47 return (ceil(sd_log2(n)) == floor(sd_log2(n)));
48 }
49
50
51
52 template<class T> inline
53 145550 fixed degrees_to_fixed(T d)
54 {
55 145550 return ftofix(DegtoFix(d));
56 }
57 template<class T> inline
58 fixed radians_to_fixed(T d)
59 {
60 return ftofix(RadtoFix(d));
61 }
62
63 BITMAP* ScriptDrawingBitmapPool::_parent_bmp = 0;
64
65 class TileHelper
66 {
67 public:
68
69 17420 static void OldPutTile(BITMAP* _Dest, int32_t tile, int32_t x, int32_t y, int32_t w, int32_t h, int32_t color, int32_t flip, byte skiprows=0)
70 {
71 // Past the end of the tile page?
72
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 17420 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
17420 if(skiprows>0 && tile%TILES_PER_ROW+w>=TILES_PER_ROW)
73 {
74 byte w2=(tile+w)%TILES_PER_ROW;
75 OldPutTile(_Dest, tile, x, y, w-w2, h, color, flip);
76 OldPutTile(_Dest, tile+(w-w2)+(skiprows*TILES_PER_ROW), x+16*(w-w2), y, w2, h, color, flip);
77 return;
78 }
79
80
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 17420 times.
17420 switch(flip)
81 {
82 case 1:
83 for(int32_t j=0; j<h; j++)
84 for(int32_t k=w-1; k>=0; k--)
85 oldputtile16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+j*16, color, flip);
86
87 break;
88
89 case 2:
90 for(int32_t j=h-1; j>=0; j--)
91 for(int32_t k=0; k<w; k++)
92 oldputtile16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+((h-1)-j)*16, color, flip);
93
94 break;
95
96 case 3:
97 for(int32_t j=h-1; j>=0; j--)
98 for(int32_t k=w-1; k>=0; k--)
99 oldputtile16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+((h-1)-j)*16, color, flip);
100
101 break;
102
103 17420 case 0:
104 default:
105
2/2
✓ Branch 0 taken 17420 times.
✓ Branch 1 taken 17420 times.
34840 for(int32_t j=0; j<h; j++)
106
2/2
✓ Branch 0 taken 17420 times.
✓ Branch 1 taken 17420 times.
34840 for(int32_t k=0; k<w; k++)
107 34840 oldputtile16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+j*16, color, flip);
108
109 17420 break;
110 }
111 17420 }
112
113 1867951 static void OverTile(BITMAP* _Dest, int32_t tile, int32_t x, int32_t y, int32_t w, int32_t h, int32_t color, int32_t flip, byte skiprows=0)
114 {
115 1867951 overtileblock16(_Dest,tile,x,y,w,h,color,flip,skiprows);
116 1867951 }
117
118 static void OverTileCloaked(BITMAP* _Dest, int32_t tile, int32_t x, int32_t y, int32_t w, int32_t h, int32_t flip, byte skiprows=0)
119 {
120 if(skiprows>0 && tile%TILES_PER_ROW+w>=TILES_PER_ROW)
121 {
122 byte w2=(tile+w)%TILES_PER_ROW;
123 OverTileCloaked(_Dest, tile, x, y, w-w2, h, flip);
124 OverTileCloaked(_Dest, tile+(w-w2)+(skiprows*TILES_PER_ROW), x+16*(w-w2), y, w2, h, flip);
125 return;
126 }
127
128 switch(flip)
129 {
130 case 1:
131 for(int32_t j=0; j<h; j++)
132 for(int32_t k=w-1; k>=0; k--)
133 overtilecloaked16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+j*16, flip);
134
135 break;
136
137 case 2:
138 for(int32_t j=h-1; j>=0; j--)
139 for(int32_t k=0; k<w; k++)
140 overtilecloaked16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+((h-1)-j)*16, flip);
141
142 break;
143
144 case 3:
145 for(int32_t j=h-1; j>=0; j--)
146 for(int32_t k=w-1; k>=0; k--)
147 overtilecloaked16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+((h-1)-j)*16, flip);
148
149 break;
150
151 default:
152 for(int32_t j=0; j<h; j++)
153 for(int32_t k=0; k<w; k++)
154 overtilecloaked16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+j*16, flip);
155
156 break;
157 }
158 }
159
160 19740 static void OverTileTranslucent(BITMAP* _Dest, int32_t tile, int32_t x, int32_t y, int32_t w, int32_t h, int32_t color, int32_t flip, int32_t opacity, byte skiprows=0)
161 {
162
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 19740 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
19740 if(skiprows>0 && tile%TILES_PER_ROW+w>=TILES_PER_ROW)
163 {
164 byte w2=(tile+w)%TILES_PER_ROW;
165 OverTileTranslucent(_Dest, tile, x, y, w-w2, h, color, flip, opacity);
166 OverTileTranslucent(_Dest, tile+(w-w2)+(skiprows*TILES_PER_ROW), x+16*(w-w2), y, w2, h, color, flip, opacity);
167 return;
168 }
169
170
1/4
✓ Branch 0 taken 19740 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
19740 switch(flip)
171 {
172 case 1:
173 for(int32_t j=0; j<h; j++)
174 for(int32_t k=w-1; k>=0; k--)
175 overtiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+j*16, color, flip, opacity);
176
177 break;
178
179 case 2:
180 for(int32_t j=h-1; j>=0; j--)
181 for(int32_t k=0; k<w; k++)
182 overtiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+((h-1)-j)*16, color, flip, opacity);
183
184 break;
185
186 case 3:
187 for(int32_t j=h-1; j>=0; j--)
188 for(int32_t k=w-1; k>=0; k--)
189 overtiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+((h-1)-j)*16, color, flip, opacity);
190
191 break;
192
193 default:
194
2/2
✓ Branch 0 taken 38102 times.
✓ Branch 1 taken 19740 times.
57842 for(int32_t j=0; j<h; j++)
195
2/2
✓ Branch 0 taken 164816 times.
✓ Branch 1 taken 38102 times.
202918 for(int32_t k=0; k<w; k++)
196 202918 overtiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+j*16, color, flip, opacity);
197
198 19740 break;
199 }
200 19740 }
201
202 static void PutTileTranslucent(BITMAP* _Dest, int32_t tile, int32_t x, int32_t y, int32_t w, int32_t h, int32_t color, int32_t flip, int32_t opacity, byte skiprows=0)
203 {
204 if(skiprows>0 && tile%TILES_PER_ROW+w>=TILES_PER_ROW)
205 {
206 byte w2=(tile+w)%TILES_PER_ROW;
207 PutTileTranslucent(_Dest, tile, x, y, w-w2, h, color, flip, opacity);
208 PutTileTranslucent(_Dest, tile+(w-w2)+(skiprows*TILES_PER_ROW), x+16*(w-w2), y, w2, h, color, flip, opacity);
209 return;
210 }
211
212 switch(flip)
213 {
214 case 1:
215 for(int32_t j=0; j<h; j++)
216 for(int32_t k=w-1; k>=0; k--)
217 puttiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+j*16, color, flip, opacity);
218
219 break;
220
221 case 2:
222 for(int32_t j=h-1; j>=0; j--)
223 for(int32_t k=0; k<w; k++)
224 puttiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+((h-1)-j)*16, color, flip, opacity);
225
226 break;
227
228 case 3:
229 for(int32_t j=h-1; j>=0; j--)
230 for(int32_t k=w-1; k>=0; k--)
231 puttiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+((h-1)-j)*16, color, flip, opacity);
232
233 break;
234
235 default:
236 for(int32_t j=0; j<h; j++)
237 for(int32_t k=0; k<w; k++)
238 puttiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+j*16, color, flip, opacity);
239
240 break;
241 }
242 }
243 };
244
245
246
247
248 1700780 void do_rectr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
249 {
250 //sdci[1]=layer
251 //sdci[2]=x
252 //sdci[3]=y
253 //sdci[4]=x2
254 //sdci[5]=y2
255 //sdci[6]=color
256 //sdci[7]=scale factor
257 //sdci[8]=rotation anchor x
258 //sdci[9]=rotation anchor y
259 //sdci[10]=rotation angle
260 //sdci[11]=fill
261 //sdci[12]=opacity
262
1/2
✓ Branch 0 taken 1700780 times.
✗ Branch 1 not taken.
1700780 if(sdci[7]==0) //scale
263 {
264 return;
265 }
266
267 1700780 int32_t x1=sdci[2]/10000;
268 1700780 int32_t y1=sdci[3]/10000;
269 1700780 int32_t x2=sdci[4]/10000;
270 1700780 int32_t y2=sdci[5]/10000;
271
272
1/2
✓ Branch 0 taken 1700780 times.
✗ Branch 1 not taken.
1700780 if(x1>x2)
273 {
274 zc_swap(x1,x2);
275 }
276
277
1/2
✓ Branch 0 taken 1700780 times.
✗ Branch 1 not taken.
1700780 if(y1>y2)
278 {
279 zc_swap(y1,y2);
280 }
281
282
2/2
✓ Branch 0 taken 1700256 times.
✓ Branch 1 taken 524 times.
1700780 if(sdci[7] != 10000)
283 {
284 524 int32_t w=x2-x1+1;
285 524 int32_t h=y2-y1+1;
286 524 int32_t w2=(w*sdci[7])/10000;
287 524 int32_t h2=(h*sdci[7])/10000;
288 524 x1=x1-((w2-w)/2);
289 524 x2=x2+((w2-w)/2);
290 524 y1=y1-((h2-h)/2);
291 524 y2=y2+((h2-h)/2);
292 524 }
293
294 1700780 int32_t color=sdci[6]/10000;
295
296
2/2
✓ Branch 0 taken 1665995 times.
✓ Branch 1 taken 34785 times.
1700780 if(sdci[12]/10000<=127) //translucent
297 {
298 34785 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
299 34785 }
300
301
2/2
✓ Branch 0 taken 23485 times.
✓ Branch 1 taken 1677295 times.
1700780 if(sdci[10]==0) //no rotation
302 {
303
2/2
✓ Branch 0 taken 378325 times.
✓ Branch 1 taken 1298970 times.
1677295 if(sdci[11]) //filled
304 {
305 1298970 rectfill(bmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
306 1298970 }
307 else //outline
308 {
309 378325 rect(bmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
310 }
311 1677295 }
312 else //rotate
313 {
314 int32_t xy[16];
315 23485 int32_t rx=sdci[8]/10000;
316 23485 int32_t ry=sdci[9]/10000;
317 23485 fixed ra1=itofix(sdci[10]%10000)/10000;
318 23485 fixed ra2=itofix(sdci[10]/10000);
319 23485 fixed ra=ra1+ra2;
320 23485 ra = (ra/360)*256;
321
322 23485 fixed fcosa = fixcos(ra);
323 23485 fixed fsina = fixsin(ra);
324
325 23485 xy[ 0]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y1 - ry))); //x1
326 23485 xy[ 1]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y1 - ry))); //y1
327 23485 xy[ 2]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y1 - ry))); //x2
328 23485 xy[ 3]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y1 - ry))); //y1
329 23485 xy[ 4]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y2 - ry))); //x2
330 23485 xy[ 5]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y2 - ry))); //y2
331 23485 xy[ 6]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y2 - ry))); //x1
332 23485 xy[ 7]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y2 - ry))); //y2
333 23485 xy[ 8]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y1 - ry + 1))); //x1
334 23485 xy[ 9]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y1 - ry + 1))); //y1
335 23485 xy[10]=xoffset+rx + fixtoi((fcosa * (x2 - rx - 1) - fsina * (y1 - ry))); //x2
336 23485 xy[11]=yoffset+ry + fixtoi((fsina * (x2 - rx - 1) + fcosa * (y1 - ry))); //y1
337 23485 xy[12]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y2 - ry - 1))); //x2
338 23485 xy[13]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y2 - ry - 1))); //y2
339 23485 xy[14]=xoffset+rx + fixtoi((fcosa * (x1 - rx + 1) - fsina * (y2 - ry))); //x1
340 23485 xy[15]=yoffset+ry + fixtoi((fsina * (x1 - rx + 1) + fcosa * (y2 - ry))); //y2
341
342
1/2
✓ Branch 0 taken 23485 times.
✗ Branch 1 not taken.
23485 if(sdci[11]) //filled
343 {
344 23485 polygon(bmp, 4, xy, color);
345 23485 }
346 else //outline
347 {
348 line(bmp, xy[0], xy[1], xy[10], xy[11], color);
349 line(bmp, xy[2], xy[3], xy[12], xy[13], color);
350 line(bmp, xy[4], xy[5], xy[14], xy[15], color);
351 line(bmp, xy[6], xy[7], xy[ 8], xy[ 9], color);
352 }
353 }
354
355 1700780 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
356 1700780 }
357
358 void do_framer(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
359 {
360 //sdci[1]=layer
361 //sdci[2]=x
362 //sdci[3]=y
363 //sdci[4]=tile
364 //sdci[5]=cset
365 //sdci[6]=width
366 //sdci[7]=height
367 //sdci[8]=overlay
368 //sdci[9]=opacity
369
370 int32_t x=sdci[2]/10000;
371 int32_t y=sdci[3]/10000;
372
373 int32_t tile=sdci[4]/10000;
374 int32_t cs=sdci[5]/10000;
375 int32_t w=sdci[6]/10000;
376 int32_t h=sdci[7]/10000;
377 bool overlay=sdci[8];
378 bool trans=(sdci[9]/10000<=127);
379
380 frame2x2(bmp, &QMisc, x + xoffset, y + yoffset, tile, cs, w, h, 0, overlay, trans);
381 }
382
383
384
385 738524 void do_circler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
386 {
387 //sdci[1]=layer
388 //sdci[2]=x
389 //sdci[3]=y
390 //sdci[4]=radius
391 //sdci[5]=color
392 //sdci[6]=scale factor
393 //sdci[7]=rotation anchor x
394 //sdci[8]=rotation anchor y
395 //sdci[9]=rotation angle
396 //sdci[10]=fill
397 //sdci[11]=opacity
398
1/2
✓ Branch 0 taken 738524 times.
✗ Branch 1 not taken.
738524 if(sdci[6]==0) //scale
399 {
400 return;
401 }
402
403 738524 int32_t x1=sdci[2]/10000;
404 738524 int32_t y1=sdci[3]/10000;
405 738524 qword r=sdci[4];
406
407
1/2
✓ Branch 0 taken 738524 times.
✗ Branch 1 not taken.
738524 if(sdci[6] != 10000)
408 {
409 r*=sdci[6];
410 r/=10000;
411 }
412
413 738524 r/=10000;
414 738524 int32_t color=sdci[5]/10000;
415
416
2/2
✓ Branch 0 taken 720724 times.
✓ Branch 1 taken 17800 times.
738524 if(sdci[11]/10000<=127) //translucent
417 {
418 17800 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
419 17800 }
420
421
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 738524 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
738524 if(sdci[9]!=0&&(sdci[2]!=sdci[7]||sdci[3]!=sdci[8])) //rotation
422 {
423 int32_t xy[2];
424 int32_t rx=sdci[7]/10000;
425 int32_t ry=sdci[8]/10000;
426 fixed ra1=itofix(sdci[9]%10000)/10000;
427 fixed ra2=itofix(sdci[9]/10000);
428 fixed ra=ra1+ra2;
429 ra = (ra/360)*256;
430
431 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
432 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
433 x1=xy[0];
434 y1=xy[1];
435 }
436
437
2/2
✓ Branch 0 taken 728196 times.
✓ Branch 1 taken 10328 times.
738524 if(sdci[10]) //filled
438 {
439 728196 circlefill(bmp, x1+xoffset, y1+yoffset, r, color);
440 728196 }
441 else //outline
442 {
443 10328 circle(bmp, x1+xoffset, y1+yoffset, r, color);
444 }
445
446 738524 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
447 738524 }
448
449
450 void do_arcr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
451 {
452 //sdci[1]=layer
453 //sdci[2]=x
454 //sdci[3]=y
455 //sdci[4]=radius
456 //sdci[5]=start angle
457 //sdci[6]=end angle
458 //sdci[7]=color
459 //sdci[8]=scale factor
460 //sdci[9]=rotation anchor x
461 //sdci[10]=rotation anchor y
462 //sdci[11]=rotation angle
463 //sdci[12]=closed
464 //sdci[13]=fill
465 //sdci[14]=opacity
466
467 if(sdci[8]==0) //scale
468 {
469 return;
470 }
471
472 int32_t cx=sdci[2]/10000;
473 int32_t cy=sdci[3]/10000;
474 qword r=sdci[4];
475
476 if(sdci[8] != 10000)
477 {
478 r*=sdci[8];
479 r/=10000;
480 }
481
482 r/=10000;
483
484 int32_t color=sdci[7]/10000;
485
486 fixed ra1=itofix(sdci[11]%10000)/10000;
487 fixed ra2=itofix(sdci[11]/10000);
488 fixed ra=ra1+ra2;
489 ra = (ra/360)*256;
490
491
492 fixed a1=itofix(sdci[5]%10000)/10000;
493 fixed a2=itofix(sdci[5]/10000);
494 fixed sa=a1+a2;
495 sa = (sa/360)*256;
496
497 a1=itofix(sdci[6]%10000)/10000;
498 a2=itofix(sdci[6]/10000);
499 fixed ea=a1+a2;
500 ea = (ea/360)*256;
501
502 if(sdci[11]!=0) //rotation
503 {
504 int32_t rx=sdci[9]/10000;
505 int32_t ry=sdci[10]/10000;
506
507 cx=rx + fixtoi((fixcos(ra) * (cx - rx) - fixsin(ra) * (cy - ry))); //x1
508 cy=ry + fixtoi((fixsin(ra) * (cx - rx) + fixcos(ra) * (cy - ry))); //y1
509 ea-=ra;
510 sa-=ra;
511 }
512
513 int32_t fx=cx+fixtoi(fixcos(-(ea+sa)/2)*r/2);
514 int32_t fy=cy+fixtoi(fixsin(-(ea+sa)/2)*r/2);
515
516 if(sdci[12]) //closed
517 {
518 if(sdci[13]) //filled
519 {
520 clear_bitmap(prim_bmp);
521 arc(prim_bmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color);
522 line(prim_bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-sa)*r), cy+yoffset+fixtoi(fixsin(-sa)*r), color);
523 line(prim_bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-ea)*r), cy+yoffset+fixtoi(fixsin(-ea)*r), color);
524 int fillx = zc_max(0,fx)+xoffset;
525 int filly = zc_max(0,fy)+yoffset;
526 zprint2("Screen->Arc fill at prim_bmp (%d,%d) - 512x512\n", fillx, filly);
527 floodfill(prim_bmp, fillx, filly, color);
528
529 if(sdci[14]/10000<=127) //translucent
530 {
531 draw_trans_sprite(bmp, prim_bmp, 0,0);
532 }
533 else
534 {
535 draw_sprite(bmp, prim_bmp, 0,0);
536 }
537 }
538 else
539 {
540 arc(bmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color);
541 line(bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-sa)*r), cy+yoffset+fixtoi(fixsin(-sa)*r), color);
542 line(bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-ea)*r), cy+yoffset+fixtoi(fixsin(-ea)*r), color);
543 }
544 }
545 else
546 {
547 if(sdci[14]/10000<=127) //translucent
548 {
549 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
550 }
551
552 arc(bmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color);
553 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
554 }
555 }
556
557
558 1850 void do_ellipser(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
559 {
560 //sdci[1]=layer
561 //sdci[2]=x
562 //sdci[3]=y
563 //sdci[4]=radiusx
564 //sdci[5]=radiusy
565 //sdci[6]=color
566 //sdci[7]=scale factor
567 //sdci[8]=rotation anchor x
568 //sdci[9]=rotation anchor y
569 //sdci[10]=rotation angle
570 //sdci[11]=fill
571 //sdci[12]=opacity
572
573
1/2
✓ Branch 0 taken 1850 times.
✗ Branch 1 not taken.
1850 if(sdci[7]==0) //scale
574 {
575 return;
576 }
577
578 1850 int32_t x1=sdci[2]/10000;
579 1850 int32_t y1=sdci[3]/10000;
580 1850 int32_t radx=sdci[4]/10000;
581 1850 radx*=sdci[7]/10000;
582 1850 int32_t rady=sdci[5]/10000;
583 1850 rady*=sdci[7]/10000;
584 1850 int32_t color=sdci[6]/10000;
585 1850 float rotation = sdci[10]/10000;
586
587 1850 int32_t rx=sdci[8]/10000;
588 1850 int32_t ry=sdci[9]/10000;
589 1850 fixed ra1=itofix(sdci[10]%10000)/10000;
590 1850 fixed ra2=itofix(sdci[10]/10000);
591 1850 fixed ra=ra1+ra2;
592 1850 ra = (ra/360)*256;
593
594 int32_t xy[2];
595 1850 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
596 1850 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
597 1850 x1=xy[0];
598 1850 y1=xy[1];
599
600
6/8
✓ Branch 0 taken 1746 times.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 1687 times.
✓ Branch 3 taken 59 times.
✓ Branch 4 taken 1687 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1687 times.
1850 if(radx<1||rady<1||radx>255||rady>255) return;
601
602 1687 BITMAP* bitty = script_drawing_commands.AquireSubBitmap(radx*2+1, rady*2+1);
603
604
2/2
✓ Branch 0 taken 1630 times.
✓ Branch 1 taken 57 times.
1687 if(sdci[11]) //filled
605 {
606
607
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 606 times.
1630 if(sdci[12]/10000<128) //translucent
608 {
609 1024 clear_bitmap(prim_bmp);
610
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 ellipsefill(bitty, radx, rady, radx, rady, color==0?255:color);
611 1024 rotate_sprite(prim_bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
612 1024 draw_trans_sprite(bmp, prim_bmp, 0, 0);
613 1024 }
614 else // no opacity
615 {
616
1/2
✓ Branch 0 taken 606 times.
✗ Branch 1 not taken.
606 ellipsefill(bitty, radx, rady, radx, rady, color==0?255:color);
617 606 rotate_sprite(bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
618 }
619 1630 }
620 else //not filled
621 {
622
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 43 times.
57 if(sdci[12]/10000<128) //translucent
623 {
624 14 clear_bitmap(prim_bmp);
625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 ellipse(bitty, radx, rady, radx, rady, color==0?255:color);
626 14 rotate_sprite(prim_bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
627 14 draw_trans_sprite(bmp, prim_bmp, 0, 0);
628 14 }
629 else // no opacity
630 {
631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 ellipse(bitty, radx, rady, radx, rady, color==0?255:color);
632 43 rotate_sprite(bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
633 }
634 }
635
636 // Since 0 is the transparent color, the stuff above will fail if the ellipse color is also 0.
637 // Instead, it uses color 255 and replaces it afterward. That'll also screw up color 255 around
638 // the ellipse, but it shouldn't be used anyway.
639
1/2
✓ Branch 0 taken 1687 times.
✗ Branch 1 not taken.
1687 if(color==0)
640 {
641 // This is very slow, so check the smallest possible square
642 int32_t endx=zc_min(bmp->w-1, x1+zc_max(radx, rady));
643 int32_t endy=zc_min(bmp->h-1, y1+zc_max(radx, rady));
644
645 for(int32_t y=zc_max(0, y1-zc_max(radx, rady)); y<=endy; y++)
646 for(int32_t x=zc_max(0, x1-zc_max(radx, rady)); x<=endx; x++)
647 if(getpixel(bmp, x, y)==255)
648 putpixel(bmp, x, y, 0);
649 }
650
651 1687 script_drawing_commands.ReleaseSubBitmap(bitty);
652 1850 }
653
654
655 29242 void do_liner(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
656 {
657 //sdci[1]=layer
658 //sdci[2]=x
659 //sdci[3]=y
660 //sdci[4]=x2
661 //sdci[5]=y2
662 //sdci[6]=color
663 //sdci[7]=scale factor
664 //sdci[8]=rotation anchor x
665 //sdci[9]=rotation anchor y
666 //sdci[10]=rotation angle
667 //sdci[11]=opacity
668
1/2
✓ Branch 0 taken 29242 times.
✗ Branch 1 not taken.
29242 if(sdci[7]==0) //scale
669 {
670 return;
671 }
672
673 29242 int32_t x1=sdci[2]/10000;
674 29242 int32_t y1=sdci[3]/10000;
675 29242 int32_t x2=sdci[4]/10000;
676 29242 int32_t y2=sdci[5]/10000;
677
678
1/2
✓ Branch 0 taken 29242 times.
✗ Branch 1 not taken.
29242 if(sdci[7] != 10000)
679 {
680 int32_t w=x2-x1+1;
681 int32_t h=y2-y1+1;
682 int32_t w2=int32_t(w*((double)sdci[7]/10000.0));
683 int32_t h2=int32_t(h*((double)sdci[7]/10000.0));
684 x1=x1-((w2-w)/2);
685 x2=x2+((w2-w)/2);
686 y1=y1-((h2-h)/2);
687 y2=y2+((h2-h)/2);
688 }
689
690 29242 int32_t color=sdci[6]/10000;
691
692
1/2
✓ Branch 0 taken 29242 times.
✗ Branch 1 not taken.
29242 if(sdci[11]/10000<=127) //translucent
693 {
694 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
695 }
696
697
1/2
✓ Branch 0 taken 29242 times.
✗ Branch 1 not taken.
29242 if(sdci[10]!=0) //rotation
698 {
699 int32_t xy[4];
700 int32_t rx=sdci[8]/10000;
701 int32_t ry=sdci[9]/10000;
702 fixed ra1=itofix(sdci[10]%10000)/10000;
703 fixed ra2=itofix(sdci[10]/10000);
704 fixed ra=ra1+ra2;
705
706 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
707 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
708 xy[ 2]=rx + fixtoi((fixcos(ra) * (x2 - rx) - fixsin(ra) * (y2 - ry))); //x2
709 xy[ 3]=ry + fixtoi((fixsin(ra) * (x2 - rx) + fixcos(ra) * (y2 - ry))); //y2
710 x1=xy[0];
711 y1=xy[1];
712 x2=xy[2];
713 y2=xy[3];
714 }
715
716 29242 line(bmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
717 29242 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
718 29242 }
719
720 void do_linesr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
721 {
722 //sdci[1]=layer
723 //sdci[2]=array[10] = { x, y, x2, y2, colour, scale, rx, ry, angle, opacity }
724
725 //sdci[2]=x
726 //sdci[3]=y
727 //sdci[4]=x2
728 //sdci[5]=y2
729 //sdci[6]=color
730 //sdci[7]=scale factor
731 //sdci[8]=rotation anchor x
732 //sdci[9]=rotation anchor y
733 //sdci[10]=rotation angle
734 //sdci[11]=opacity
735 //if(sdci[7]==0) //scale
736 //{
737 // return;
738 //}
739
740 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
741
742 if(!v_ptr)
743 {
744 al_trace("Screen->PutPixels: Vector pointer is null! Internal error. \n");
745 return;
746 }
747
748 std::vector<int32_t> &v = *v_ptr;
749
750 if(v.empty())
751 return;
752 //Z_scripterrlog("PutPixels reached line %d\n", 983);
753
754 int32_t* pos = &v[0];
755 int32_t sz = v.size();
756
757 for ( int32_t q = 0; q < sz; q+=10 )
758 {
759
760 int32_t x1 = v.at(q);
761 Z_scripterrlog("Lines( x1 ) is: %d\n", x1);
762 int32_t y1 = v.at(q+1);
763 Z_scripterrlog("Lines( x2 ) is: %d\n", y1);
764 int32_t x2 = v.at(q+2);
765 Z_scripterrlog("Lines( x2 ) is: %d\n", x2);
766 int32_t y2 = v.at(q+3);
767 Z_scripterrlog("Lines( y2 ) is: %d\n", y2);
768 int32_t color = v.at(q+4);
769 Z_scripterrlog("Lines( colour ) is: %d\n", color);
770 Z_scripterrlog("Lines( scale ) is: %d\n", v.at(q+5));
771 if (v.at(q+5) == 0) { Z_scripterrlog("Lines() aborting due to scale\n"); return; }//scale
772
773 if( v.at(q+5) != 10000)
774 {
775 int32_t w=x2-x1+1;
776 int32_t h=y2-y1+1;
777 int32_t w2=int32_t(w*((double)v.at(q+5)));
778 int32_t h2=int32_t(h*((double)v.at(q+5)));
779 x1=x1-((w2-w)/2);
780 x2=x2+((w2-w)/2);
781 y1=y1-((h2-h)/2);
782 y2=y2+((h2-h)/2);
783 }
784
785
786 Z_scripterrlog("Lines( opacity ) is: %d\n", v.at(q+9));
787 if(v.at(q+9) <= 127) //translucent
788 {
789 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
790 }
791 else drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
792 Z_scripterrlog("Lines( rotation ) is: %d\n", v.at(q+8));
793 Z_scripterrlog("Lines( rot_x ) is: %d\n", v.at(q+6));
794 Z_scripterrlog("Lines( rot_x ) is: %d\n", v.at(q+7));
795 if( v.at(q+8) !=0 ) //rotation
796 {
797 int32_t xy[4];
798
799 int32_t rx = v.at(q+6);
800
801 int32_t ry = v.at(q+7);
802
803 fixed ra1=itofix(v.at(q+8) % 1);
804 fixed ra2=itofix(v.at(q+8));
805 fixed ra=ra1+ra2;
806
807 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
808 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
809 xy[ 2]=rx + fixtoi((fixcos(ra) * (x2 - rx) - fixsin(ra) * (y2 - ry))); //x2
810 xy[ 3]=ry + fixtoi((fixsin(ra) * (x2 - rx) + fixcos(ra) * (y2 - ry))); //y2
811 x1=xy[0];
812 y1=xy[1];
813 x2=xy[2];
814 y2=xy[3];
815 }
816 Z_scripterrlog("Lines( xofs ) is: %d\n", xoffset);
817 Z_scripterrlog("Lines( yofs ) is: %d\n", yoffset);
818 line(bmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
819 }
820 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
821 }
822
823 void do_polygonr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
824 {
825 //sdci[1]=layer
826 //sdci[2]=point count
827 //sdci[3]array[]
828 //sdci[4] = colour
829 //sdci[5] = opacity
830
831 int32_t col = sdci[4]/10000;
832 int32_t op = sdci[5]/10000;
833
834 //bool brokenOffset= ( (get_bit(extra_rules, er_BITMAPOFFSET)!=0) || (get_bit(quest_rules,qr_BITMAPOFFSETFIX)!=0) );
835 //Z_scripterrlog("Broken offset rule for Polygon() is: %s\n", brokenOffset ? "ON" : "OFF");
836 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
837
838 if(!v_ptr)
839 {
840 al_trace("Screen->Polygon: Vector pointer is null! Internal error. \n");
841 return;
842 }
843
844 std::vector<int32_t> &v = *v_ptr;
845
846 if(v.empty())
847 return;
848 //Z_scripterrlog("PutPixels reached line %d\n", 983);
849
850 int32_t* pos = &v[0];
851 int32_t sz = v.size();
852 int32_t numpoints = (sdci[2]/10000);
853 if(sz & 1) --sz; //even amount only
854 if(numpoints > sz/2) //cap to array
855 numpoints = sz/2;
856 if(numpoints < 1)
857 return; //Don't draw 0 or negative point count
858
859 //Fix the draw Y offset. -Z 20th June, 2019
860 for ( int32_t q = 1; q < sz; q+=2 )
861 {
862 pos[q] += yoffset;
863 }
864 if(op <= 127) //translucent
865 {
866 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
867 }
868 else drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
869
870 polygon(bmp, numpoints, (int32_t*)pos, col);
871 //polygon(bmp, (sdci[2]/10000), &v, col);
872 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
873 }
874
875 void bmp_do_polygonr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
876 {
877 //sdci[1]=layer
878 //sdci[2]=point count
879 //sdci[3]array[]
880 //sdci[4] = colour
881 //sdci[5] = opacity
882
883 int32_t col = sdci[4]/10000;
884 int32_t op = sdci[5]/10000;
885
886 if ( sdci[17] <= 0 )
887 {
888 Z_scripterrlog("bitmap->Rectangle() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
889 return;
890 }
891 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
892 if ( refbmp == NULL ) return;
893
894 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
895
896 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
897
898 if(!v_ptr)
899 {
900 al_trace("Screen->Polygon: Vector pointer is null! Internal error. \n");
901 return;
902 }
903
904 std::vector<int32_t> &v = *v_ptr;
905
906 if(v.empty())
907 return;
908 //Z_scripterrlog("PutPixels reached line %d\n", 983);
909
910 int32_t* pos = &v[0];
911 int32_t sz = v.size();
912 int32_t numpoints = (sdci[2]/10000);
913 if(sz & 1) --sz; //even amount only
914 if(numpoints > sz/2) //cap to array
915 numpoints = sz/2;
916 if(numpoints < 1)
917 return; //Don't draw 0 or negative point count
918
919 //Fix the draw Y offset. -Z 20th June, 2019
920 for ( int32_t q = 1; q < sz; q+=2 )
921 {
922 pos[q] += yoffset;
923 }
924 if(op <= 127) //translucent
925 {
926 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
927 }
928 else drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
929
930 polygon(refbmp, numpoints, (int32_t*)pos, col);
931 //polygon(refbmp, (sdci[2]/10000), &v, col);
932 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
933 }
934
935 void do_spliner(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
936 {
937 /* layer, x1, y1, x2, y2, x3, y3, x4, y4, color, opacity */
938
939 int32_t points[8] = { xoffset + (sdci[2]/10000), yoffset + (sdci[3]/10000),
940 xoffset + (sdci[4]/10000), yoffset + (sdci[5]/10000),
941 xoffset + (sdci[6]/10000), yoffset + (sdci[7]/10000),
942 xoffset + (sdci[8]/10000), yoffset + (sdci[9]/10000)
943 };
944
945 if(sdci[11]/10000 < 128) //translucent
946 {
947 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
948 }
949
950 spline(bmp, points, sdci[10]/10000);
951
952 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
953 }
954
955
956 261359 void do_putpixelr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
957 {
958 //sdci[1]=layer
959 //sdci[2]=x
960 //sdci[3]=y
961 //sdci[4]=color
962 //sdci[5]=rotation anchor x
963 //sdci[6]=rotation anchor y
964 //sdci[7]=rotation angle
965 //sdci[8]=opacity
966 261359 int32_t x1=sdci[2]/10000;
967 261359 int32_t y1=sdci[3]/10000;
968 261359 int32_t color=sdci[4]/10000;
969
970
2/2
✓ Branch 0 taken 261343 times.
✓ Branch 1 taken 16 times.
261359 if(sdci[8]/10000<=127) //translucent
971 {
972 16 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
973 16 }
974
975
1/2
✓ Branch 0 taken 261359 times.
✗ Branch 1 not taken.
261359 if(sdci[7]!=0) //rotation
976 {
977 int32_t xy[2];
978 int32_t rx=sdci[5]/10000;
979 int32_t ry=sdci[6]/10000;
980 fixed ra1=itofix(sdci[7]%10000)/10000;
981 fixed ra2=itofix(sdci[7]/10000);
982 fixed ra=ra1+ra2;
983
984 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
985 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
986 x1=xy[0];
987 y1=xy[1];
988 }
989
990 261359 putpixel(bmp, x1+xoffset, y1+yoffset, color);
991 261359 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
992 261359 }
993
994 void do_putpixelsr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
995 {
996 //Z_scripterrlog("Starting putpixels()%s\n");
997 //sdci[1]=layer
998 //sdci[2]=array {x,y,colour,opacity}
999 //sdci[3]=rotation anchor x
1000 //sdci[4]=rotation anchor y
1001 //sdci[5]=rotation angle
1002
1003
1004 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
1005
1006 if(!v_ptr)
1007 {
1008 al_trace("Screen->PutPixels: Vector pointer is null! Internal error. \n");
1009 return;
1010 }
1011
1012 std::vector<int32_t> &v = *v_ptr;
1013
1014 if(v.empty())
1015 return;
1016 //Z_scripterrlog("PutPixels reached line %d\n", 983);
1017
1018 int32_t* pos = &v[0];
1019 int32_t sz = v.size();
1020 //Z_scripterrlog("Vector size is: %d\n", sz);
1021 //for ( int32_t m = 0; m < 256; ++m ) Z_scripterrlog("Vector contents at pos[%d]: %d\n", m, pos[m]);
1022
1023 //FFCore.getValues(sdci[2]/10000, points, sz);
1024
1025
1026 int32_t x1 = 0;
1027 int32_t y1 = 0;
1028
1029 for ( int32_t q = 0; q < sz; q+=4 )
1030 {
1031 //Z_scripterrlog("Vector q: %d\n", q);
1032 //if ( q > sz-1 ) break;
1033 x1 = v.at(q); //pos[q];
1034 y1 = v.at(q+1); //pos[q+1];
1035 //Z_scripterrlog("x1 is: %d\n", x1);
1036 //Z_scripterrlog("y1 is: %d\n", 1);
1037 if(sdci[5]!=0) //rotation
1038 {
1039 int32_t xy[2];
1040 int32_t rx=sdci[3]/10000;
1041 int32_t ry=sdci[4]/10000;
1042 fixed ra1=itofix(sdci[5]%10000)/10000;
1043 fixed ra2=itofix(sdci[5]/10000);
1044 fixed ra=ra1+ra2;
1045
1046 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
1047 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
1048 x1=xy[0];
1049 y1=xy[1];
1050 }
1051 //Z_scripterrlog("PutPixels()%s value is %d\n","x",x1);
1052 //Z_scripterrlog("PutPixels()%s value is %d\n","y",y1);
1053 //Z_scripterrlog("PutPixels()%s value is %d\n","colour",points[q+2]);
1054 if ( v.at(q+3) /*pos[q+3]*/ < 128 ) drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
1055 else drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
1056 putpixel(bmp, x1+xoffset, y1+yoffset, v.at(q+2) /*pos[q+2]*/);
1057 //if ( points[q+3] < 128 )
1058
1059 //else drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
1060 }
1061 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
1062 }
1063
1064 761909 void do_drawtiler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1065 {
1066 //sdci[1]=layer
1067 //sdci[2]=x
1068 //sdci[3]=y
1069 //sdci[4]=tile
1070 //sdci[5]=tile width
1071 //sdci[6]=tile height
1072 //sdci[7]=color (cset)
1073 //sdci[8]=scale x
1074 //sdci[9]=scale y
1075 //sdci[10]=rotation anchor x
1076 //sdci[11]=rotation anchor y
1077 //sdci[12]=rotation angle
1078 //sdci[13]=flip
1079 //sdci[14]=transparency
1080 //sdci[15]=opacity
1081
1082 761909 int32_t w = sdci[5]/10000;
1083 761909 int32_t h = sdci[6]/10000;
1084
1085
4/8
✓ Branch 0 taken 761909 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 761909 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 761909 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 761909 times.
761909 if(w < 1 || h < 1 || h > 20 || w > 20)
1086 {
1087 return;
1088 }
1089
1090 761909 int32_t xscale=sdci[8]/10000;
1091 761909 int32_t yscale=sdci[9]/10000;
1092 761909 int32_t rx = sdci[10]/10000;
1093 761909 int32_t ry = sdci[11]/10000;
1094 761909 float rotation=sdci[12]/10000;
1095 761909 int32_t flip=(sdci[13]/10000)&3;
1096 761909 bool transparency=sdci[14]!=0;
1097 761909 int32_t opacity=sdci[15]/10000;
1098 761909 int32_t color=sdci[7]/10000;
1099
1100 761909 int32_t x1=sdci[2]/10000;
1101 761909 int32_t y1=sdci[3]/10000;
1102
1103 //don't scale if it's not safe to do so
1104 761909 bool canscale = true;
1105
1106
3/4
✓ Branch 0 taken 760870 times.
✓ Branch 1 taken 1039 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 760870 times.
761909 if(xscale==0||yscale==0)
1107 {
1108 1039 return;
1109 }
1110
1111
3/4
✓ Branch 0 taken 68399 times.
✓ Branch 1 taken 692471 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 68399 times.
760870 if(xscale<=0||yscale<=0)
1112 692471 canscale = false; //default size
1113
1114
4/4
✓ Branch 0 taken 68399 times.
✓ Branch 1 taken 692471 times.
✓ Branch 2 taken 39135 times.
✓ Branch 3 taken 653336 times.
760870 if((xscale>0 && yscale>0) || rotation) //scaled or rotated
1115 {
1116 107534 BITMAP* pbitty = script_drawing_commands.AquireSubBitmap(w*16, h*16);
1117
1118
1/2
✓ Branch 0 taken 107534 times.
✗ Branch 1 not taken.
107534 if(transparency) //transparency
1119 {
1120 107534 TileHelper::OverTile(pbitty, (sdci[4]/10000), 0, 0, w, h, color, flip);
1121 107534 }
1122 else //no transparency
1123 {
1124 TileHelper::OldPutTile(pbitty, (sdci[4]/10000), 0, 0, w, h, color, flip);
1125 }
1126
1127
2/2
✓ Branch 0 taken 42823 times.
✓ Branch 1 taken 64711 times.
107534 if(rotation != 0)
1128 {
1129 //low negative values indicate no anchor-point rotation
1130
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 42823 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
42823 if(rx>-777||ry>-777)
1131 {
1132 int32_t xy[2];
1133 42823 fixed ra1=itofix(sdci[12]%10000)/10000;
1134 42823 fixed ra2=itofix(sdci[12]/10000);
1135 42823 fixed ra=ra1+ra2;
1136 42823 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
1137 42823 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
1138 42823 x1=xy[0];
1139 42823 y1=xy[1];
1140 42823 }
1141
1142
2/2
✓ Branch 0 taken 3688 times.
✓ Branch 1 taken 39135 times.
42823 if(canscale) //scale first
1143 {
1144 //damnit all, .. fixme.
1145
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3688 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3688 times.
3688 BITMAP* tempbit = create_bitmap_ex(8, xscale>512?512:xscale, yscale>512?512:yscale);
1146 3688 clear_bitmap(tempbit);
1147
1148 3688 stretch_sprite(tempbit, pbitty, 0, 0, xscale, yscale);
1149
1150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3688 times.
3688 if(opacity < 128)
1151 {
1152 clear_bitmap(prim_bmp);
1153 rotate_sprite(prim_bmp, tempbit, 0, 0, degrees_to_fixed(rotation));
1154 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1155 }
1156 else
1157 {
1158 3688 rotate_sprite(bmp, tempbit, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
1159 }
1160
1161 3688 destroy_bitmap(tempbit);
1162 3688 }
1163 else //no scale
1164 {
1165
2/2
✓ Branch 0 taken 336 times.
✓ Branch 1 taken 38799 times.
39135 if(opacity < 128)
1166 {
1167 336 clear_bitmap(prim_bmp);
1168 336 rotate_sprite(prim_bmp, pbitty, 0, 0, degrees_to_fixed(rotation));
1169 336 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1170 336 }
1171 else
1172 {
1173 38799 rotate_sprite(bmp, pbitty, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
1174 }
1175 }
1176 42823 }
1177 else //scale only
1178 {
1179
1/2
✓ Branch 0 taken 64711 times.
✗ Branch 1 not taken.
64711 if(canscale)
1180 {
1181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64711 times.
64711 if(opacity<128)
1182 {
1183 clear_bitmap(prim_bmp);
1184 stretch_sprite(prim_bmp, pbitty, 0, 0, xscale, yscale);
1185 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1186 }
1187 else
1188 {
1189 64711 stretch_sprite(bmp, pbitty, x1+xoffset, y1+yoffset, xscale, yscale);
1190 }
1191 64711 }
1192 else //error -do not scale
1193 {
1194 if(opacity<128)
1195 {
1196 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1197 }
1198 else
1199 {
1200 draw_sprite(bmp, pbitty, x1+xoffset, y1+yoffset);
1201 }
1202 }
1203 }
1204
1205 107534 script_drawing_commands.ReleaseSubBitmap(pbitty);
1206
1207 107534 }
1208 else // no scale or rotation
1209 {
1210
1/2
✓ Branch 0 taken 653336 times.
✗ Branch 1 not taken.
653336 if(transparency)
1211 {
1212
2/2
✓ Branch 0 taken 7384 times.
✓ Branch 1 taken 645952 times.
653336 if(opacity<=127)
1213 7384 TileHelper::OverTileTranslucent(bmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip, opacity);
1214 else
1215 645952 TileHelper::OverTile(bmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip);
1216 653336 }
1217 else
1218 {
1219 if(opacity<=127)
1220 TileHelper::PutTileTranslucent(bmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip, opacity);
1221 else
1222 TileHelper::OldPutTile(bmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip);
1223 }
1224 }
1225 761909 }
1226
1227 void do_drawtilecloakedr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1228 {
1229 //sdci[1]=layer
1230 //sdci[2]=x
1231 //sdci[3]=y
1232 //sdci[4]=tile
1233 //sdci[5]=tile width
1234 //sdci[6]=tile height
1235 //sdci[7]=flip
1236
1237 int32_t w = sdci[5]/10000;
1238 int32_t h = sdci[6]/10000;
1239
1240 if(w < 1 || h < 1 || h > 20 || w > 20)
1241 {
1242 return;
1243 }
1244
1245 int32_t flip=(sdci[7]/10000)&3;
1246
1247 int32_t x1=sdci[2]/10000;
1248 int32_t y1=sdci[3]/10000;
1249
1250 TileHelper::OverTileCloaked(bmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, flip);
1251 }
1252
1253
1254 1074739 void do_drawcombor(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1255 {
1256 //sdci[1]=layer
1257 //sdci[2]=x
1258 //sdci[3]=y
1259 //sdci[4]=combo
1260 //sdci[5]=tile width
1261 //sdci[6]=tile height
1262 //sdci[7]=color (cset)
1263 //sdci[8]=scale x
1264 //sdci[9]=scale y
1265 //sdci[10]=rotation anchor x
1266 //sdci[11]=rotation anchor y
1267 //sdci[12]=rotation angle
1268 //sdci[13]=frame
1269 //sdci[14]=flip
1270 //sdci[15]=transparency
1271 //sdci[16]=opacity
1272
1273 1074739 int32_t w = sdci[5]/10000;
1274 1074739 int32_t h = sdci[6]/10000;
1275
1276
4/8
✓ Branch 0 taken 1074739 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1074739 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1074739 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1074739 times.
1074739 if(w<1||h<1||h>20||w>20)
1277 {
1278 return;
1279 }
1280 1074739 int32_t cmb = (sdci[4]/10000);
1281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1074739 times.
1074739 if((unsigned)cmb >= MAXCOMBOS)
1282 {
1283 Z_scripterrlog("DrawCombo() cannot draw combo '%d', as it is out of bounds.\n", cmb);
1284 return;
1285 }
1286
1287 1074739 int32_t xscale=sdci[8]/10000;
1288 1074739 int32_t yscale=sdci[9]/10000;
1289 1074739 int32_t rx = sdci[10]/10000; //these work now
1290 1074739 int32_t ry = sdci[11]/10000; //these work now
1291 1074739 float rotation=sdci[12]/10000;
1292
1293 1074739 bool transparency=sdci[15]!=0;
1294 1074739 int32_t opacity=sdci[16]/10000;
1295 1074739 int32_t color=sdci[7]/10000;
1296 1074739 int32_t x1=sdci[2]/10000;
1297 1074739 int32_t y1=sdci[3]/10000;
1298
1299 1074739 const newcombo & c = combobuf[cmb];
1300 1074739 int32_t tiletodraw = combo_tile(c, x1, y1);
1301 1074739 int32_t flip = ((sdci[14]/10000) & 3) ^ c.flip;
1302 1074739 int32_t skiprows=c.skipanimy;
1303
1304
1305 //don't scale if it's not safe to do so
1306 1074739 bool canscale = true;
1307
1308
3/4
✓ Branch 0 taken 1074723 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1074723 times.
1074739 if(xscale==0||yscale==0)
1309 {
1310 16 return;
1311 }
1312
1313
3/4
✓ Branch 0 taken 13100 times.
✓ Branch 1 taken 1061623 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13100 times.
1074723 if(xscale<=0||yscale<=0)
1314 1061623 canscale = false; //default size
1315
1316
4/4
✓ Branch 0 taken 13100 times.
✓ Branch 1 taken 1061623 times.
✓ Branch 2 taken 94250 times.
✓ Branch 3 taken 967373 times.
1074723 if((xscale>0 && yscale>0) || rotation) //scaled or rotated
1317 {
1318 107350 BITMAP* pbitty = script_drawing_commands.AquireSubBitmap(w*16, h*16); //-pbitty in the hisouse. :D
1319
1320
1/2
✓ Branch 0 taken 107350 times.
✗ Branch 1 not taken.
107350 if(transparency)
1321 {
1322 107350 TileHelper::OverTile(pbitty, tiletodraw, 0, 0, w, h, color, flip, skiprows);
1323 107350 }
1324 else //no transparency
1325 {
1326 TileHelper::OldPutTile(pbitty, tiletodraw, 0, 0, w, h, color, flip, skiprows);
1327 }
1328
1329
2/2
✓ Branch 0 taken 94359 times.
✓ Branch 1 taken 12991 times.
107350 if(rotation != 0) // rotate
1330 {
1331 //fixed point sucks ;0
1332
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94359 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94359 if(rx>-777||ry>-777) //set the rotation anchor and rotate around that
1333 {
1334 int32_t xy[2];
1335 94359 fixed ra1=itofix(sdci[12]%10000)/10000;
1336 94359 fixed ra2=itofix(sdci[12]/10000);
1337 94359 fixed ra=ra1+ra2;
1338 94359 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
1339 94359 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
1340 94359 x1=xy[0];
1341 94359 y1=xy[1];
1342 94359 }
1343
1344
2/2
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 94250 times.
94359 if(canscale) //scale first
1345 {
1346
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 109 times.
109 BITMAP* tempbit = create_bitmap_ex(8, xscale>512?512:xscale, yscale>512?512:yscale);
1347 109 clear_bitmap(tempbit);
1348
1349 109 stretch_sprite(tempbit, pbitty, 0, 0, xscale, yscale);
1350
1351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(opacity < 128)
1352 {
1353 clear_bitmap(prim_bmp);
1354 rotate_sprite(prim_bmp, tempbit, 0, 0, degrees_to_fixed(rotation));
1355 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1356 }
1357 else
1358 {
1359 109 rotate_sprite(bmp, tempbit, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
1360 }
1361
1362 109 destroy_bitmap(tempbit);
1363 109 }
1364 else //no scale
1365 {
1366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94250 times.
94250 if(opacity < 128)
1367 {
1368 clear_bitmap(prim_bmp);
1369 rotate_sprite(prim_bmp, pbitty, 0, 0, degrees_to_fixed(rotation));
1370 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1371 }
1372 else
1373 {
1374 94250 rotate_sprite(bmp, pbitty, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
1375 }
1376 }
1377 94359 }
1378 else //scale only
1379 {
1380
1/2
✓ Branch 0 taken 12991 times.
✗ Branch 1 not taken.
12991 if(canscale)
1381 {
1382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12991 times.
12991 if(opacity<128)
1383 {
1384 clear_bitmap(prim_bmp);
1385 stretch_sprite(prim_bmp, pbitty, 0, 0, xscale, yscale);
1386 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1387 }
1388 else
1389 {
1390 12991 stretch_sprite(bmp, pbitty, x1+xoffset, y1+yoffset, xscale, yscale);
1391 }
1392 12991 }
1393 else //error -do not scale
1394 {
1395 if(opacity<128)
1396 {
1397 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1398 }
1399 else
1400 {
1401 draw_sprite(bmp, pbitty, x1+xoffset, y1+yoffset);
1402 }
1403 }
1404 }
1405
1406 107350 script_drawing_commands.ReleaseSubBitmap(pbitty); //rap sucks
1407 107350 }
1408 else // no scale or rotation
1409 {
1410
1/2
✓ Branch 0 taken 967373 times.
✗ Branch 1 not taken.
967373 if(transparency)
1411 {
1412
2/2
✓ Branch 0 taken 12356 times.
✓ Branch 1 taken 955017 times.
967373 if(opacity<=127)
1413 12356 TileHelper::OverTileTranslucent(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, opacity, skiprows);
1414 else
1415 955017 TileHelper::OverTile(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, skiprows);
1416 967373 }
1417 else
1418 {
1419 if(opacity<=127)
1420 TileHelper::PutTileTranslucent(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, opacity, skiprows);
1421 else
1422 TileHelper::OldPutTile(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, skiprows);
1423 }
1424 }
1425 1074739 }
1426
1427 void do_drawcombocloakedr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1428 {
1429 //sdci[1]=layer
1430 //sdci[2]=x
1431 //sdci[3]=y
1432 //sdci[4]=combo
1433 //sdci[5]=tile width
1434 //sdci[6]=tile height
1435 //sdci[7]=flip
1436
1437 int32_t w = sdci[5]/10000;
1438 int32_t h = sdci[6]/10000;
1439
1440 if(w<1||h<1||h>20||w>20)
1441 {
1442 return;
1443 }
1444 int32_t cmb = (sdci[4]/10000);
1445 if((unsigned)cmb >= MAXCOMBOS)
1446 {
1447 Z_scripterrlog("DrawComboCloaked() cannot draw combo '%d', as it is out of bounds.\n", cmb);
1448 return;
1449 }
1450
1451 int32_t x1=sdci[2]/10000;
1452 int32_t y1=sdci[3]/10000;
1453
1454 const newcombo & c = combobuf[cmb];
1455 int32_t tiletodraw = combo_tile(c, x1, y1);
1456 int32_t flip = ((sdci[7]/10000) & 3) ^ c.flip;
1457 int32_t skiprows=c.skipanimy;
1458
1459 TileHelper::OverTileCloaked(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, flip, skiprows);
1460 }
1461
1462
1463 2787748 void do_fasttiler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1464 {
1465 /* layer, x, y, tile, color opacity */
1466
1467 2787748 int32_t opacity = sdci[6]/10000;
1468
1469
2/2
✓ Branch 0 taken 9944 times.
✓ Branch 1 taken 2777804 times.
2787748 if(opacity < 128)
1470 9944 overtiletranslucent16(bmp, sdci[4]/10000, xoffset+(sdci[2]/10000), yoffset+(sdci[3]/10000), sdci[5]/10000, 0, opacity);
1471 else
1472 2777804 overtile16(bmp, sdci[4]/10000, xoffset+(sdci[2]/10000), yoffset+(sdci[3]/10000), sdci[5]/10000, 0);
1473 2787748 }
1474
1475 void do_fasttilesr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1476 {
1477 /* layer, x, y, tile, color opacity */
1478
1479 //sdci[1]=layer
1480 //sdci[2]=array {x,y,tile,colour,opacity}
1481
1482 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
1483
1484 if(!v_ptr)
1485 {
1486 al_trace("Screen->PutPixels: Vector pointer is null! Internal error. \n");
1487 return;
1488 }
1489
1490 std::vector<int32_t> &v = *v_ptr;
1491
1492 if(v.empty())
1493 return;
1494 //Z_scripterrlog("PutPixels reached line %d\n", 983);
1495
1496 int32_t* pos = &v[0];
1497 int32_t sz = v.size();
1498
1499 for ( int32_t q = 0; q < sz; q+=5 )
1500 {
1501
1502 if(v.at(q+4) < 128)
1503 overtiletranslucent16(bmp, v.at(q), xoffset+(v.at(q+1)), yoffset+(v.at(q+2)), v.at(q+3), 0, v.at(q+4));
1504 else
1505 overtile16(bmp, v.at(q), xoffset+(v.at(q+1)), yoffset+(v.at(q+2)), v.at(q+3), 0);
1506 }
1507 }
1508
1509
1510
1511 7495889 void do_fastcombor(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1512 {
1513 /* layer, x, y, tile, color opacity */
1514
1515 7495889 int32_t opacity = sdci[6] / 10000;
1516 7495889 int32_t x1 = sdci[2] / 10000;
1517 7495889 int32_t y1 = sdci[3] / 10000;
1518
1519 7495889 int32_t cmb = (sdci[4]/10000);
1520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7495889 times.
7495889 if((unsigned)cmb >= MAXCOMBOS)
1521 {
1522 Z_scripterrlog("FastCombo() cannot draw combo '%d', as it is out of bounds.\n", cmb);
1523 return;
1524 }
1525 //if( index >= MAXCOMBOS ) return; //bleh.
1526 /*
1527 const newcombo & c = combobuf[index];
1528
1529 if(opacity < 128)
1530 overtiletranslucent16(bmp, combo_tile(c, x1, y1), xoffset+x1, yoffset+y1, sdci[5]/10000, (int32_t)c.flip, opacity);
1531 else
1532 overtile16(bmp, combo_tile(c, x1, y1), xoffset+x1, yoffset+y1, sdci[5]/10000, (int32_t)c.flip);
1533 */
1534
1535
2/2
✓ Branch 0 taken 2485 times.
✓ Branch 1 taken 7493404 times.
7495889 if(opacity < 128)
1536 {
1537 //void overcomboblocktranslucent(BITMAP *dest, int32_t x, int32_t y, int32_t cmbdat, int32_t cset, int32_t w, int32_t h, int32_t opacity)
1538 2485 overcomboblocktranslucent(bmp, xoffset+x1, yoffset+y1, cmb, sdci[5]/10000, 1, 1, 128);
1539
1540 2485 }
1541 else
1542 {
1543 //overcomboblock(BITMAP *dest, int32_t x, int32_t y, int32_t cmbdat, int32_t cset, int32_t w, int32_t h)
1544 7493404 overcomboblock(bmp, xoffset+x1, yoffset+y1, cmb, sdci[5]/10000, 1, 1);
1545 }
1546 7495889 }
1547
1548 void do_fastcombosr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1549 {
1550 /* layer, x, y, combo, cset, opacity */
1551
1552 //sdci[1]=layer
1553 //sdci[2]=array {x,y,combo,cset,opacity}
1554
1555 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
1556
1557 if(!v_ptr)
1558 {
1559 al_trace("Screen->FastCombos: Vector pointer is null! Internal error. \n");
1560 return;
1561 }
1562
1563 std::vector<int32_t> &v = *v_ptr;
1564
1565 if(v.empty())
1566 return;
1567
1568 int32_t* pos = &v[0];
1569 int32_t sz = v.size();
1570
1571 for ( int32_t q = 0; q < sz; q+=5 )
1572 {
1573 if((unsigned)(v.at(q+2)) >= MAXCOMBOS)
1574 {
1575 Z_scripterrlog("FastCombos() cannot draw combo '%d', as it is out of bounds.\n", v.at(q+2));
1576 continue;
1577 }
1578 if(v.at(q+4) < 128)
1579 {
1580 //void overcomboblocktranslucent(BITMAP *dest, int32_t x, int32_t y, int32_t cmbdat, int32_t cset, int32_t w, int32_t h, int32_t opacity)
1581 overcomboblocktranslucent(bmp, xoffset+v.at(q), yoffset+v.at(q+1), v.at(q+2), v.at(q+3), 1, 1, 128);
1582
1583 }
1584 else
1585 {
1586 //overcomboblock(BITMAP *dest, int32_t x, int32_t y, int32_t cmbdat, int32_t cset, int32_t w, int32_t h)
1587 overcomboblock(bmp, xoffset+v.at(q), yoffset+v.at(q+1), v.at(q+2), v.at(q+3), 1, 1);
1588 }
1589 }
1590 }
1591
1592
1593
1594
1595 12044 void do_drawcharr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1596 {
1597 //broken 2.50.2 and earlier drawcharacter()
1598
2/2
✓ Branch 0 taken 11595 times.
✓ Branch 1 taken 449 times.
12044 if ( get_bit(quest_rules, qr_BROKENCHARINTDRAWING) )
1599 {
1600 //sdci[1]=layer
1601 //sdci[2]=x
1602 //sdci[3]=y
1603 //sdci[4]=font
1604 //sdci[5]=color
1605 //sdci[6]=bg color
1606 //sdci[7]=strech x (width)
1607 //sdci[8]=stretch y (height)
1608 //sdci[9]=char
1609 //sdci[10]=opacity
1610
1611 11595 int32_t x=sdci[2]/10000;
1612 11595 int32_t y=sdci[3]/10000;
1613 11595 int32_t font_index=sdci[4]/10000;
1614 11595 int32_t color=sdci[5]/10000;
1615 11595 int32_t bg_color=sdci[6]/10000; //-1 = transparent
1616 11595 int32_t w=sdci[7]/10000;
1617 11595 int32_t h=sdci[8]/10000;
1618 11595 char glyph=char(sdci[9]/10000);
1619 11595 int32_t opacity=sdci[10]/10000;
1620
1621 //safe check
1622
1/2
✓ Branch 0 taken 11595 times.
✗ Branch 1 not taken.
11595 if(bg_color < -1) bg_color = -1;
1623
1624
1/2
✓ Branch 0 taken 11595 times.
✗ Branch 1 not taken.
11595 if(w>512) w=512; //w=vbound(w,0,512);
1625
1626
1/2
✓ Branch 0 taken 11595 times.
✗ Branch 1 not taken.
11595 if(h>512) h=512; //h=vbound(h,0,512);
1627
1628 //undone
1629
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11595 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11595 if(w>0&&h>0)//stretch the character
1630 {
1631 BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1);
1632
1633 if(opacity < 128)
1634 {
1635 if(w>128||h>128)
1636 {
1637 clear_bitmap(prim_bmp);
1638
1639 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1640 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
1641 draw_trans_sprite(bmp, prim_bmp, x+xoffset, y+yoffset);
1642 }
1643 else //this is faster
1644 {
1645 BITMAP *pbmp2 = script_drawing_commands.AquireSubBitmap(w,h);
1646
1647 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1648 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
1649 draw_trans_sprite(bmp, pbmp2, x+xoffset, y+yoffset);
1650
1651 script_drawing_commands.ReleaseSubBitmap(pbmp2);
1652 }
1653 }
1654 else // no opacity
1655 {
1656 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1657 stretch_sprite(bmp, pbmp, x+xoffset, y+yoffset, w, h);
1658 }
1659
1660 }
1661 else //no stretch
1662 {
1663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11595 times.
11595 if(opacity < 128)
1664 {
1665 BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16);
1666 clear_bitmap(pbmp);
1667
1668 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1669 draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset);
1670
1671 destroy_bitmap(pbmp);
1672 }
1673 else // no opacity
1674 {
1675 11595 textprintf_ex(bmp, get_zc_font(font_index), x+xoffset, y+yoffset, color, bg_color, "%c", glyph);
1676 }
1677 }
1678 11595 }
1679
1680 else //2.53.0 fixed version and later.
1681 {
1682
1683 //sdci[1]=layer
1684 //sdci[2]=x
1685 //sdci[3]=y
1686 //sdci[4]=font
1687 //sdci[5]=color
1688 //sdci[6]=bg color
1689 //sdci[7]=strech x (width)
1690 //sdci[8]=stretch y (height)
1691 //sdci[9]=char
1692 //sdci[10]=opacity
1693
1694 449 int32_t x=sdci[2]/10000;
1695 449 int32_t y=sdci[3]/10000;
1696 449 int32_t font_index=sdci[4]/10000;
1697 449 int32_t color=sdci[5]/10000;
1698 449 int32_t bg_color=sdci[6]/10000; //-1 = transparent
1699 449 int32_t w=sdci[7]/10000;
1700 449 int32_t h=sdci[8]/10000;
1701 449 char glyph=char(sdci[9]/10000);
1702 449 int32_t opacity=sdci[10]/10000;
1703
1704 //safe check
1705
1/2
✓ Branch 0 taken 449 times.
✗ Branch 1 not taken.
449 if(bg_color < -1) bg_color = -1;
1706
1707
1/2
✓ Branch 0 taken 449 times.
✗ Branch 1 not taken.
449 if(w>512) w=512; //w=vbound(w,0,512);
1708
1709
1/2
✓ Branch 0 taken 449 times.
✗ Branch 1 not taken.
449 if(h>512) h=512; //h=vbound(h,0,512);
1710
1711 //undone
1712
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 449 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
449 if(w>0&&h>0)//stretch the character
1713 {
1714 BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1);
1715
1716 if(opacity < 128)
1717 {
1718 if(w>128||h>128)
1719 {
1720 clear_bitmap(prim_bmp);
1721
1722 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1723 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
1724 draw_trans_sprite(bmp, prim_bmp, x+xoffset, y+yoffset);
1725 }
1726 else //this is faster
1727 {
1728 BITMAP *pbmp2 = script_drawing_commands.AquireSubBitmap(w,h);
1729
1730 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1731 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
1732 draw_trans_sprite(bmp, pbmp2, x+xoffset, y+yoffset);
1733
1734 script_drawing_commands.ReleaseSubBitmap(pbmp2);
1735 }
1736 }
1737 else // no opacity
1738 {
1739 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1740 stretch_sprite(bmp, pbmp, x+xoffset, y+yoffset, w, h);
1741 }
1742
1743 }
1744 else //no stretch
1745 {
1746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 449 times.
449 if(opacity < 128)
1747 {
1748 BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16);
1749 clear_bitmap(pbmp);
1750
1751 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1752 draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset);
1753
1754 destroy_bitmap(pbmp);
1755 }
1756 else // no opacity
1757 {
1758 449 textprintf_ex(bmp, get_zc_font(font_index), x+xoffset, y+yoffset, color, bg_color, "%c", glyph);
1759 }
1760 }
1761
1762 }
1763
1764 12044 }
1765
1766
1767 36046 void do_drawintr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1768 {
1769 //broken 2.50.2 and earlier drawinteger()
1770
2/2
✓ Branch 0 taken 35718 times.
✓ Branch 1 taken 328 times.
36046 if ( get_bit(quest_rules, qr_BROKENCHARINTDRAWING) )
1771 {
1772 //sdci[1]=layer
1773 //sdci[2]=x
1774 //sdci[3]=y
1775 //sdci[4]=font
1776 //sdci[5]=color
1777 //sdci[6]=bg color
1778 //sdci[7]=strech x (width)
1779 //sdci[8]=stretch y (height)
1780 //sdci[9]=integer
1781 //sdci[10]=num decimal places
1782 //sdci[11]=opacity
1783
1784 35718 int32_t x=sdci[2]/10000;
1785 35718 int32_t y=sdci[3]/10000;
1786 35718 int32_t font_index=sdci[4]/10000;
1787 35718 int32_t color=sdci[5]/10000;
1788 35718 int32_t bg_color=sdci[6]/10000; //-1 = transparent
1789 35718 int32_t w=sdci[7]/10000;
1790 35718 int32_t h=sdci[8]/10000;
1791 //float number=static_cast<float>(sdci[9])/10000.0f;
1792 35718 int32_t decplace=sdci[10]/10000;
1793 35718 int32_t opacity=sdci[11]/10000;
1794
1795 //safe check
1796
1/2
✓ Branch 0 taken 35718 times.
✗ Branch 1 not taken.
35718 if(bg_color < -1) bg_color = -1;
1797
1798
1/2
✓ Branch 0 taken 35718 times.
✗ Branch 1 not taken.
35718 if(w>512) w=512; //w=vbound(w,0,512);
1799
1800
1/2
✓ Branch 0 taken 35718 times.
✗ Branch 1 not taken.
35718 if(h>512) h=512; //h=vbound(h,0,512);
1801
1802 char numbuf[15];
1803
1804
1/6
✓ Branch 0 taken 35718 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35718 switch(decplace)
1805 {
1806 default:
1807 case 0:
1808 35718 sprintf(numbuf,"%d",(sdci[9]/10000)); //For some reason, static casting for zero decimal places was
1809 35718 break; //reducing the value by -1, so 8.000 printed as '7'. -Z
1810
1811 case 1:
1812 //sprintf(numbuf,"%.01f",number);
1813 sprintf(numbuf,"%.01f",(static_cast<float>(sdci[9])/10000.0f)); //Would this be slower?
1814 break;
1815
1816 case 2:
1817 //sprintf(numbuf,"%.02f",number);
1818 sprintf(numbuf,"%.02f",(static_cast<float>(sdci[9])/10000.0f));
1819 break;
1820
1821 case 3:
1822 //sprintf(numbuf,"%.03f",number);
1823 sprintf(numbuf,"%.03f",(static_cast<float>(sdci[9])/10000.0f));
1824 break;
1825
1826 case 4:
1827 //sprintf(numbuf,"%.04f",number);
1828 sprintf(numbuf,"%.04f",(static_cast<float>(sdci[9])/10000.0f));
1829 break;
1830 }
1831
1832
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 35718 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
35718 if(w>0&&h>0)//stretch
1833 {
1834 BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1);
1835
1836 if(opacity < 128)
1837 {
1838 if(w>128||h>128)
1839 {
1840 clear_bitmap(prim_bmp);
1841
1842 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
1843 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
1844 draw_trans_sprite(bmp, prim_bmp, x+xoffset, y+yoffset);
1845 }
1846 else
1847 {
1848 BITMAP *pbmp2 = create_sub_bitmap(prim_bmp,0,0,w,h);
1849 clear_bitmap(pbmp2);
1850
1851 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
1852 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
1853 draw_trans_sprite(bmp, pbmp2, x+xoffset, y+yoffset);
1854
1855 destroy_bitmap(pbmp2);
1856 }
1857 }
1858 else // no opacity
1859 {
1860 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
1861 stretch_sprite(bmp, pbmp, x+xoffset, y+yoffset, w, h);
1862 }
1863
1864 }
1865 else //no stretch
1866 {
1867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35718 times.
35718 if(opacity < 128)
1868 {
1869 BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16);
1870 clear_bitmap(pbmp);
1871
1872 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
1873 draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset);
1874
1875 destroy_bitmap(pbmp);
1876 }
1877 else // no opacity
1878 {
1879 35718 textout_ex(bmp, get_zc_font(font_index), numbuf, x+xoffset, y+yoffset, color, bg_color);
1880 }
1881 }
1882
1883 35718 }
1884
1885 else //2.53.0 fixed version and later.
1886 {
1887 //sdci[1]=layer
1888 //sdci[2]=x
1889 //sdci[3]=y
1890 //sdci[4]=font
1891 //sdci[5]=color
1892 //sdci[6]=bg color
1893 //sdci[7]=strech x (width)
1894 //sdci[8]=stretch y (height)
1895 //sdci[9]=integer
1896 //sdci[10]=num decimal places
1897 //sdci[11]=opacity
1898
1899 328 int32_t x=sdci[2]/10000;
1900 328 int32_t y=sdci[3]/10000;
1901 328 int32_t font_index=sdci[4]/10000;
1902 328 int32_t color=sdci[5]/10000;
1903 328 int32_t bg_color=sdci[6]/10000; //-1 = transparent
1904 328 int32_t w=sdci[7]/10000;
1905 328 int32_t h=sdci[8]/10000;
1906 //float number=static_cast<float>(sdci[9])/10000.0f;
1907 //int32_t numberint = sdci[9]/10000;
1908 328 int32_t decplace=sdci[10]/10000;
1909 328 int32_t opacity=sdci[11]/10000;
1910
1911 //safe check
1912
1/2
✓ Branch 0 taken 328 times.
✗ Branch 1 not taken.
328 if(bg_color < -1) bg_color = -1;
1913
1914
1/2
✓ Branch 0 taken 328 times.
✗ Branch 1 not taken.
328 if(w>512) w=512; //w=vbound(w,0,512);
1915
1916
1/2
✓ Branch 0 taken 328 times.
✗ Branch 1 not taken.
328 if(h>512) h=512; //h=vbound(h,0,512);
1917
1918 char numbuf[15];
1919
1920
1/6
✓ Branch 0 taken 328 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
328 switch(decplace)
1921 {
1922 default:
1923 case 0:
1924 328 sprintf(numbuf,"%d",(sdci[9]/10000)); //For some reason, static casting for zero decimal places was
1925 328 break; //reducing the value by -1, so 8.000 printed as '7'. -Z
1926
1927 case 1:
1928 //sprintf(numbuf,"%.01f",number);
1929 sprintf(numbuf,"%.01f",(static_cast<float>(sdci[9])/10000.0f)); //Would this be slower?
1930 break;
1931
1932 case 2:
1933 //sprintf(numbuf,"%.02f",number);
1934 sprintf(numbuf,"%.02f",(static_cast<float>(sdci[9])/10000.0f));
1935 break;
1936
1937 case 3:
1938 //sprintf(numbuf,"%.03f",number);
1939 sprintf(numbuf,"%.03f",(static_cast<float>(sdci[9])/10000.0f));
1940 break;
1941
1942 case 4:
1943 //sprintf(numbuf,"%.04f",number);
1944 sprintf(numbuf,"%.04f",(static_cast<float>(sdci[9])/10000.0f));
1945 break;
1946 }
1947
1948 //FONT* font=get_zc_font(sdci[4]/10000);
1949
1950
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 328 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
328 if(w>0&&h>0)//stretch
1951 {
1952 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, text_length(get_zc_font(font_index), numbuf)+1, text_height(get_zc_font(font_index)));
1953 clear_bitmap(pbmp);
1954 //script_drawing_commands.GetSmallTextureBitmap(1,1);
1955
1956 if(opacity < 128)
1957 {
1958 if(w>128||h>128)
1959 {
1960 clear_bitmap(prim_bmp);
1961
1962 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
1963 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
1964 draw_trans_sprite(bmp, prim_bmp, x+xoffset, y+yoffset);
1965 }
1966 else
1967 {
1968 BITMAP *pbmp2 = create_sub_bitmap(prim_bmp,0,0,w,h);
1969 clear_bitmap(pbmp2);
1970
1971 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
1972 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
1973 draw_trans_sprite(bmp, pbmp2, x+xoffset, y+yoffset);
1974
1975 destroy_bitmap(pbmp2);
1976 }
1977 }
1978 else // no opacity
1979 {
1980 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
1981 stretch_sprite(bmp, pbmp, x+xoffset, y+yoffset, w, h);
1982 }
1983
1984 }
1985 else //no stretch
1986 {
1987
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 328 times.
328 if(opacity < 128)
1988 {
1989 FONT* font = get_zc_font(font_index);
1990 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, text_length(font, numbuf), text_height(font));
1991 clear_bitmap(pbmp);
1992
1993 textout_ex(pbmp, font, numbuf, 0, 0, color, bg_color);
1994 draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset);
1995
1996 destroy_bitmap(pbmp);
1997 }
1998 else // no opacity
1999 {
2000 328 textout_ex(bmp, get_zc_font(font_index), numbuf, x+xoffset, y+yoffset, color, bg_color);
2001 }
2002 }
2003 }
2004 36046 }
2005
2006
2007 386173 void do_drawstringr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
2008 {
2009 //sdci[1]=layer
2010 //sdci[2]=x
2011 //sdci[3]=y
2012 //sdci[4]=font
2013 //sdci[5]=color
2014 //sdci[6]=bg color
2015 //sdci[7]=format_option
2016 //sdci[8]=string
2017 //sdci[9]=opacity
2018
2019 386173 std::string* str = (std::string*)script_drawing_commands[i].GetPtr();
2020
2021
1/2
✓ Branch 0 taken 386173 times.
✗ Branch 1 not taken.
386173 if(!str)
2022 {
2023 al_trace("String pointer is null! Internal error. \n");
2024 return;
2025 }
2026
2027 386173 int32_t x=sdci[2]/10000;
2028 386173 int32_t y=sdci[3]/10000;
2029 386173 FONT* font=get_zc_font(sdci[4]/10000);
2030 386173 int32_t color=sdci[5]/10000;
2031 386173 int32_t bg_color=sdci[6]/10000; //-1 = transparent
2032 386173 int32_t format_type=sdci[7]/10000;
2033 386173 int32_t opacity=sdci[9]/10000;
2034 //sdci[8] not needed :)
2035
2036 //safe check
2037
1/2
✓ Branch 0 taken 386173 times.
✗ Branch 1 not taken.
386173 if(bg_color < -1) bg_color = -1;
2038
2039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 386173 times.
386173 if(opacity < 128)
2040 {
2041 int32_t width=zc_min(text_length(font, str->c_str()), 512);
2042 if (width < 1) return; //SANITY -Em
2043 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, width, text_height(font));
2044 clear_bitmap(pbmp);
2045 textout_ex(pbmp, font, str->c_str(), 0, 0, color, bg_color);
2046 if(format_type == 2) // right-sided text
2047 x-=width;
2048 else if(format_type == 1) // centered text
2049 x-=width/2;
2050 draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset);
2051 destroy_bitmap(pbmp);
2052 }
2053 else // no opacity
2054 {
2055
2/2
✓ Branch 0 taken 24808 times.
✓ Branch 1 taken 361365 times.
386173 if(format_type == 2) // right-sided text
2056 {
2057 24808 textout_right_ex(bmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color);
2058 24808 }
2059
2/2
✓ Branch 0 taken 62342 times.
✓ Branch 1 taken 299023 times.
361365 else if(format_type == 1) // centered text
2060 {
2061 62342 textout_centre_ex(bmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color);
2062 62342 }
2063 else // standard left-sided text
2064 {
2065 299023 textout_ex(bmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color);
2066 }
2067 }
2068 386173 }
2069
2070 153213 void do_drawstringr2(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
2071 {
2072 //sdci[1]=layer
2073 //sdci[2]=x
2074 //sdci[3]=y
2075 //sdci[4]=font
2076 //sdci[5]=color
2077 //sdci[6]=bg color
2078 //sdci[7]=format_option
2079 //sdci[8]=string
2080 //sdci[9]=opacity
2081 //sdci[10]=shadowtype
2082 //sdci[11]=shadow_color
2083
2084 153213 std::string* str = (std::string*)script_drawing_commands[i].GetPtr();
2085
2086
1/2
✓ Branch 0 taken 153213 times.
✗ Branch 1 not taken.
153213 if(!str)
2087 {
2088 al_trace("String pointer is null! Internal error. \n");
2089 return;
2090 }
2091
2092 153213 int32_t x=sdci[2]/10000;
2093 153213 int32_t y=sdci[3]/10000;
2094 153213 FONT* font=get_zc_font(sdci[4]/10000);
2095 153213 int32_t color=sdci[5]/10000;
2096 153213 int32_t bg_color=sdci[6]/10000; //-1 = transparent
2097 153213 int32_t format_type=sdci[7]/10000;
2098 153213 int32_t opacity=sdci[9]/10000;
2099 153213 int32_t textstyle = sdci[10]/10000;
2100 153213 int32_t shadow_color = sdci[11]/10000;
2101 //sdci[8] not needed :)
2102
2103 //safe check
2104
1/2
✓ Branch 0 taken 153213 times.
✗ Branch 1 not taken.
153213 if(bg_color < -1) bg_color = -1;
2105
2106
2/2
✓ Branch 0 taken 740 times.
✓ Branch 1 taken 152473 times.
153213 if(opacity < 128)
2107 {
2108
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 int32_t width=zc_min(text_length(font, str->c_str()), 512);
2109
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if (width < 1) return; //SANITY -Em
2110 740 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, width, text_height(font));
2111 740 clear_bitmap(pbmp);
2112 740 textout_styled_aligned_ex(pbmp, font, str->c_str(), 0, 0, textstyle, sstaLEFT, color, shadow_color, bg_color);
2113 740 textout_ex(pbmp, font, str->c_str(), 0, 0, color, bg_color);
2114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 740 times.
740 if(format_type == 2) // right-sided text
2115 x-=width;
2116
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 else if(format_type == 1) // centered text
2117 740 x-=width/2;
2118 740 draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset);
2119 740 destroy_bitmap(pbmp);
2120 740 }
2121 else // no opacity
2122 {
2123 152473 textout_styled_aligned_ex(bmp, font, str->c_str(), x+xoffset, y+yoffset, textstyle, format_type, color, shadow_color, bg_color);
2124 }
2125 153213 }
2126
2127
2128 9266 void do_drawquadr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
2129 {
2130 //sdci[1]=layer
2131 //sdci[2]=x1
2132 //sdci[3]=y1
2133 //sdci[4]=x2
2134 //sdci[5]=y2
2135 //sdci[6]=x3
2136 //sdci[7]=y3
2137 //sdci[8]=x4
2138 //sdci[9]=y4
2139 //sdci[10]=width
2140 //sdci[11]=height
2141 //sdci[12]=cset
2142 //sdci[13]=flip
2143 //sdci[14]=tile/combo
2144 //sdci[15]=polytype
2145
2146 9266 int32_t x1 = sdci[2]/10000;
2147 9266 int32_t y1 = sdci[3]/10000;
2148 9266 int32_t x2 = sdci[4]/10000;
2149 9266 int32_t y2 = sdci[5]/10000;
2150 9266 int32_t x3 = sdci[6]/10000;
2151 9266 int32_t y3 = sdci[7]/10000;
2152 9266 int32_t x4 = sdci[8]/10000;
2153 9266 int32_t y4 = sdci[9]/10000;
2154 9266 int32_t w = sdci[10]/10000;
2155 9266 int32_t h = sdci[11]/10000;
2156 9266 int32_t color = sdci[12]/10000;
2157 9266 int32_t flip=(sdci[13]/10000)&3;
2158 9266 int32_t tile = sdci[14]/10000;
2159 9266 int32_t polytype = sdci[15]/10000;
2160
2161 //todo: finish palette shading
2162 /*
2163 POLYTYPE_FLAT
2164 POLYTYPE_GCOL
2165 POLYTYPE_GRGB
2166 POLYTYPE_ATEX
2167 POLYTYPE_PTEX
2168 POLYTYPE_ATEX_MASK
2169 POLYTYPE_PTEX_MASK
2170 POLYTYPE_ATEX_LIT
2171 POLYTYPE_PTEX_LIT
2172 POLYTYPE_ATEX_MASK_LIT
2173 POLYTYPE_PTEX_MASK_LIT
2174 POLYTYPE_ATEX_TRANS
2175 POLYTYPE_PTEX_TRANS
2176 POLYTYPE_ATEX_MASK_TRANS
2177 POLYTYPE_PTEX_MASK_TRANS
2178 */
2179 9266 polytype = vbound(polytype, 0, 14);
2180
2181
2/4
✓ Branch 0 taken 9266 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9266 times.
9266 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
2182 {
2183 Z_message("Quad() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
2184 return; //non power of two error
2185 }
2186
2187 9266 int32_t tex_width = w*16;
2188 9266 int32_t tex_height = h*16;
2189
2190 BITMAP *tex;
2191
2192 9266 bool mustDestroyBmp = false;
2193
2194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9266 times.
9266 if ( tile > 65519 ) tex = zscriptDrawingRenderTarget->GetBitmapPtr(tile - 65519);
2195 9266 else tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
2196
2197
1/2
✓ Branch 0 taken 9266 times.
✗ Branch 1 not taken.
9266 if(!tex)
2198 {
2199 mustDestroyBmp = true;
2200 tex = create_bitmap_ex(8, tex_width, tex_height);
2201 clear_bitmap(tex);
2202 }
2203
2204 int32_t col[4];
2205 /*
2206 if( color < 0 )
2207 {
2208 col[0]=draw_container.color_buffer[0];
2209 col[1]=draw_container.color_buffer[1];
2210 col[2]=draw_container.color_buffer[2];
2211 col[3]=draw_container.color_buffer[3];
2212 }
2213 else */
2214 {
2215 9266 col[0]=col[1]=col[2]=col[3]=color;
2216 }
2217
2218
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9266 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9266 if(tile > 0 && tile <= 65519) // TILE
2219 {
2220 TileHelper::OverTile(tex, tile, 0, 0, w, h, color, flip);
2221 }
2222
2223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9266 times.
9266 if ( tile < 0 ) // COMBO
2224 {
2225 9266 const newcombo & c = combobuf[ vbound(abs(tile), 0, 0xffff) ];
2226 9266 const int32_t tiletodraw = combo_tile(c, x1, y1);
2227 9266 flip = flip ^ c.flip;
2228
2229 9266 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, color, flip);
2230 9266 }
2231
2232 9266 V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] };
2233 9266 V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(tex_height), col[1] };
2234 9266 V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(tex_width), static_cast<float>(tex_height), col[2] };
2235 9266 V3D_f V4 = { static_cast<float>(x4+xoffset), static_cast<float>(y4+yoffset), 0, static_cast<float>(tex_width), 0, col[3] };
2236
2237 9266 quad3d_f(bmp, polytype, tex, &V1, &V2, &V3, &V4);
2238
2239
1/2
✓ Branch 0 taken 9266 times.
✗ Branch 1 not taken.
9266 if(mustDestroyBmp)
2240 destroy_bitmap(tex);
2241
2242 9266 }
2243
2244
2245 void do_drawtriangler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
2246 {
2247 //sdci[1]=layer
2248 //sdci[2]=x1
2249 //sdci[3]=y1
2250 //sdci[4]=x2
2251 //sdci[5]=y2
2252 //sdci[6]=x3
2253 //sdci[7]=y3
2254 //sdci[8]=width
2255 //sdci[9]=height
2256 //sdci[10]=cset
2257 //sdci[11]=flip
2258 //sdci[12]=tile/combo
2259 //sdci[13]=polytype
2260
2261 int32_t x1 = sdci[2]/10000;
2262 int32_t y1 = sdci[3]/10000;
2263 int32_t x2 = sdci[4]/10000;
2264 int32_t y2 = sdci[5]/10000;
2265 int32_t x3 = sdci[6]/10000;
2266 int32_t y3 = sdci[7]/10000;
2267 int32_t w = sdci[8]/10000;
2268 int32_t h = sdci[9]/10000;
2269 int32_t color = sdci[10]/10000;
2270 int32_t flip=(sdci[11]/10000)&3;
2271 int32_t tile = sdci[12]/10000;
2272 int32_t polytype = sdci[13]/10000;
2273
2274 polytype = vbound(polytype, 0, 14);
2275
2276 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
2277 {
2278 Z_message("Quad() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
2279 return; //non power of two error
2280 }
2281
2282 int32_t tex_width = w*16;
2283 int32_t tex_height = h*16;
2284
2285 bool mustDestroyBmp = false;
2286 BITMAP *tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
2287
2288 if(!tex)
2289 {
2290 mustDestroyBmp = true;
2291 tex = create_bitmap_ex(8, tex_width, tex_height);
2292 clear_bitmap(tex);
2293 }
2294
2295 int32_t col[3];
2296 /*
2297 if( color < 0 )
2298 {
2299 col[0]=draw_container.color_buffer[0];
2300 col[1]=draw_container.color_buffer[1];
2301 col[2]=draw_container.color_buffer[2];
2302 }
2303 else */
2304 {
2305 col[0]=col[1]=col[2]=color;
2306 }
2307
2308 if(tile > 0) // TILE
2309 {
2310 TileHelper::OverTile(tex, tile, 0, 0, w, h, color, flip);
2311 }
2312 else // COMBO
2313 {
2314 const newcombo & c = combobuf[ vbound(abs(tile), 0, 0xffff) ];
2315 const int32_t tiletodraw = combo_tile(c, x1, y1);
2316 flip = flip ^ c.flip;
2317
2318 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, color, flip);
2319 }
2320
2321 V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] };
2322 V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(tex_height), col[1] };
2323 V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(tex_width), static_cast<float>(tex_height), col[2] };
2324
2325
2326 triangle3d_f(bmp, polytype, tex, &V1, &V2, &V3);
2327
2328 if(mustDestroyBmp)
2329 destroy_bitmap(tex);
2330 }
2331
2332
2333 777927 void do_drawbitmapr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
2334 {
2335 //sdci[1]=layer
2336 //sdci[2]=bitmap
2337 //sdci[3]=sourcex
2338 //sdci[4]=sourcey
2339 //sdci[5]=sourcew
2340 //sdci[6]=sourceh
2341 //sdci[7]=destx
2342 //sdci[8]=desty
2343 //sdci[9]=destw
2344 //sdci[10]=desth
2345 //sdci[11]=rotation
2346 //sdci[12]=mask
2347
2348 777927 int32_t bitmapIndex = sdci[2]/10000;
2349 777927 int32_t sx = sdci[3]/10000;
2350 777927 int32_t sy = sdci[4]/10000;
2351 777927 int32_t sw = sdci[5]/10000;
2352 777927 int32_t sh = sdci[6]/10000;
2353 777927 int32_t dx = sdci[7]/10000;
2354 777927 int32_t dy = sdci[8]/10000;
2355 777927 int32_t dw = sdci[9]/10000;
2356 777927 int32_t dh = sdci[10]/10000;
2357 777927 float rot = sdci[11]/10000;
2358 777927 bool masked = (sdci[12] != 0);
2359
2360 //bugfix
2361 777927 sx = vbound(sx, 0, 512);
2362 777927 sy = vbound(sy, 0, 512);
2363 777927 sw = vbound(sw, 0, 512 - sx); //keep the w/h within range as well
2364 777927 sh = vbound(sh, 0, 512 - sy);
2365
2366
2367
2/4
✓ Branch 0 taken 777927 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 777927 times.
777927 if(sx >= ZScriptDrawingRenderTarget::BitmapWidth || sy >= ZScriptDrawingRenderTarget::BitmapHeight)
2368 return;
2369
2370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 777927 times.
777927 bool stretched = (sw != dw || sh != dh);
2371
2372 777927 BITMAP *sourceBitmap = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex);
2373
2374
1/2
✓ Branch 0 taken 777927 times.
✗ Branch 1 not taken.
777927 if(!sourceBitmap)
2375 {
2376 Z_message("Warning: Screen->DrawBitmap(%d) contains invalid data or is not initialized.\n", bitmapIndex);
2377 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
2378 return;
2379 }
2380
2381 777927 BITMAP* subBmp = 0;
2382
2383
1/2
✓ Branch 0 taken 777927 times.
✗ Branch 1 not taken.
777927 if(rot != 0)
2384 {
2385 subBmp = script_drawing_commands.AquireSubBitmap(dw, dh);
2386
2387 if(!subBmp)
2388 {
2389 Z_scripterrlog("DrawBitmap() failed to create a sub-bitmap to use for %s. Aborting.\n", "rotation");
2390 return;
2391 }
2392 }
2393
2394
2395 777927 dx = dx + xoffset;
2396 777927 dy = dy + yoffset;
2397
2398
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 777687 times.
777927 if(stretched)
2399 {
2400
1/2
✓ Branch 0 taken 240 times.
✗ Branch 1 not taken.
240 if(masked)
2401 {
2402
1/2
✓ Branch 0 taken 240 times.
✗ Branch 1 not taken.
240 if(rot != 0)
2403 {
2404 //if ( rot == 4096 ) { //translucent
2405 // masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2406 // //rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2407 // draw_trans_sprite(bmp, subBmp, dx, dy);
2408 // //draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, 0);
2409
2410
2411 // }
2412 //else {
2413 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2414 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2415 //rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2416 //
2417
2418 // }
2419 }
2420 else
2421 240 masked_stretch_blit(sourceBitmap, bmp, sx, sy, sw, sh, dx, dy, dw, dh);
2422 240 }
2423 else
2424 {
2425 if(rot != 0)
2426 {
2427 //if ( rot == 4096 ) { //translucent
2428 // stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2429 // draw_trans_sprite(bmp, subBmp, dx, dy);
2430 // }
2431 //else {
2432 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2433 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2434 // }
2435 }
2436 else
2437 stretch_blit(sourceBitmap, bmp, sx, sy, sw, sh, dx, dy, dw, dh);
2438 }
2439 240 }
2440 else
2441 {
2442
1/2
✓ Branch 0 taken 777687 times.
✗ Branch 1 not taken.
777687 if(masked)
2443 {
2444
1/2
✓ Branch 0 taken 777687 times.
✗ Branch 1 not taken.
777687 if(rot != 0)
2445 {
2446 //if ( rot == 4096 ) {//translucent
2447 // masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
2448 //rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2449
2450 //masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2451 //rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2452 // draw_trans_sprite(bmp, subBmp, dx, dy);
2453 // }
2454 //else {
2455 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
2456 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2457 // }
2458 }
2459 else
2460 777687 masked_blit(sourceBitmap, bmp, sx, sy, dx, dy, dw, dh);
2461 777687 }
2462 else
2463 {
2464 if(rot != 0)
2465 {
2466 //if ( rot == 4096 ) { //translucent
2467 // blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
2468 // draw_trans_sprite(bmp, subBmp, dx, dy);
2469 // }
2470 //else {
2471 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
2472 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2473 // }
2474 }
2475 else
2476 blit(sourceBitmap, bmp, sx, sy, dx, dy, dw, dh);
2477 }
2478 }
2479
2480 //cleanup
2481
1/2
✓ Branch 0 taken 777927 times.
✗ Branch 1 not taken.
777927 if(subBmp)
2482 {
2483 script_drawing_commands.ReleaseSubBitmap(subBmp);
2484 }
2485 777927 }
2486
2487
2488 //Draw]()
2489 void do_drawbitmapexr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
2490 {
2491 /*
2492 //sdci[1]=layer
2493 //sdci[2]=bitmap
2494 //sdci[3]=sourcex
2495 //sdci[4]=sourcey
2496 //sdci[5]=sourcew
2497 //sdci[6]=sourceh
2498 //sdci[7]=destx
2499 //sdci[8]=desty
2500 //sdci[9]=destw
2501 //sdci[10]=desth
2502 //sdci[11]=rotation/angle
2503 //scdi[12] = pivot cx
2504 //sdci[13] = pivot cy
2505 //scdi[14] = effect flags
2506
2507
2508 const int32_t BITDX_NORMAL = 0;
2509 const int32_t BITDX_TRANS = 1; //Translucent
2510 const int32_t BITDX_PIVOT = 2; //THe sprite will rotate at a specific point, instead of its center.
2511 const int32_t BITDX_HFLIP = 4; //Horizontal Flip
2512 const int32_t BITDX_VFLIP = 8; //Vertical Flip.
2513 //Note: Some modes cannot be combined. if a combination is not supported, an error
2514 // detailing this will be shown in allegro.log.
2515
2516 //scdi[15] = litcolour
2517 //The allegro docs are wrong. The params are: rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
2518 /not rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2519
2520 //sdci[16]=mask
2521
2522 */
2523
2524 int32_t bitmapIndex = sdci[2]/10000;
2525 int32_t sx = sdci[3]/10000;
2526 int32_t sy = sdci[4]/10000;
2527 int32_t sw = sdci[5]/10000;
2528 int32_t sh = sdci[6]/10000;
2529 int32_t dx = sdci[7]/10000;
2530 int32_t dy = sdci[8]/10000;
2531 int32_t dw = sdci[9]/10000;
2532 int32_t dh = sdci[10]/10000;
2533 float rot = sdci[11]/10000;
2534 int32_t cx = sdci[12]/10000;
2535 int32_t cy = sdci[13]/10000;
2536 int32_t mode = sdci[14]/10000;
2537 int32_t litcolour = sdci[15]/10000;
2538 bool masked = (sdci[16] != 0);
2539
2540
2541
2542 //bugfix
2543 sx = vbound(sx, 0, 512);
2544 sy = vbound(sy, 0, 512);
2545 sw = vbound(sw, 0, 512 - sx); //keep the w/h within range as well
2546 sh = vbound(sh, 0, 512 - sy);
2547
2548
2549 if(sx >= ZScriptDrawingRenderTarget::BitmapWidth || sy >= ZScriptDrawingRenderTarget::BitmapHeight)
2550 return;
2551
2552 bool stretched = (sw != dw || sh != dh);
2553
2554 BITMAP *sourceBitmap = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex);
2555
2556 if(!sourceBitmap)
2557 {
2558 Z_message("Warning: Screen->DrawBitmap(%d) contains invalid data or is not initialized.\n", bitmapIndex);
2559 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
2560 return;
2561 }
2562
2563 BITMAP* subBmp = 0;
2564
2565 /*
2566 if ( bitmapIndex == -1 ) {
2567 blit(bmp, sourceBitmap, sx, sy, 0, 0, dw, dh);
2568 }
2569 */
2570
2571 if(rot != 0 || mode != 0)
2572 {
2573 subBmp = script_drawing_commands.AquireSubBitmap(dw, dh);
2574
2575 if(!subBmp)
2576 {
2577 Z_scripterrlog("bitmap->Blit failed to create a sub-bitmap to use for %s. Aborting.\n", "rotation");
2578 return;
2579 }
2580 }
2581
2582
2583 dx = dx + xoffset;
2584 dy = dy + yoffset;
2585
2586 if(stretched)
2587 {
2588 if(masked) //stretched and masked
2589 {
2590 if ( rot == 0 ) //if not rotated
2591 {
2592 switch(mode)
2593 {
2594 case 1:
2595 //transparent
2596 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2597 draw_trans_sprite(bmp, subBmp, dx, dy);
2598 break;
2599
2600
2601 case 2:
2602 //pivot?
2603 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2604 pivot_sprite(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
2605 //Pivoting requires two more args
2606 break;
2607
2608 case 3:
2609 //pivot + trans
2610 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2611 pivot_sprite_trans(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
2612 break;
2613
2614 case 4:
2615 //flip v
2616 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2617 draw_sprite_v_flip(bmp, subBmp, dx, dy);
2618 break;
2619
2620 case 5:
2621 //trans + v flip
2622 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2623 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
2624 break;
2625
2626 case 6:
2627 //pivot + v flip
2628 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2629 pivot_sprite_v_flip(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
2630 break;
2631
2632 case 8:
2633 //vlip h
2634 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2635 draw_sprite_h_flip(bmp, subBmp, dx, dy);
2636 break;
2637
2638 case 9:
2639 //trans + h flip
2640 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2641 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
2642 break;
2643
2644 case 10:
2645 //flip H and pivot
2646 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
2647 //return error cannot pivot and h flip
2648 break;
2649
2650 case 12:
2651 //vh flip
2652 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2653 draw_sprite_vh_flip(bmp, subBmp, dx, dy);
2654 break;
2655
2656 case 13:
2657 //trans + vh flip
2658 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2659 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
2660 break;
2661
2662 case 14:
2663 //pivot and vh flip
2664 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
2665 //return error cannot both pivot and vh flip
2666 break;
2667
2668 case 16:
2669 //lit
2670 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2671 draw_lit_sprite(bmp, subBmp, dx, dy, litcolour);
2672 break;
2673
2674 case 18:
2675 //pivot, lit
2676 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2677 pivot_sprite_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
2678 break;
2679
2680 case 20:
2681 //lit + v flip
2682 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2683 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
2684 break;
2685
2686 case 22:
2687 //Pivot, vflip, lit
2688 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2689 pivot_sprite_v_flip_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
2690 break;
2691
2692 case 24:
2693 //lit + h flip
2694 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2695 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
2696 break;
2697
2698 case 26:
2699 //pivot + lit + hflip
2700 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
2701 //return error cannot pivot, lit, and flip
2702 break;
2703
2704 case 28:
2705 //lit + vh flip
2706 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2707 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
2708 break;
2709
2710 case 32: //gouraud
2711 //Probably not wort supporting.
2712 //masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2713 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
2714 break;
2715
2716 case 0:
2717 //no effect
2718 masked_stretch_blit(sourceBitmap, bmp, sx, sy, sw, sh, dx, dy, dw, dh);
2719 break;
2720
2721
2722 default:
2723 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
2724
2725
2726 }
2727 } //end if not rotated
2728
2729 if ( rot != 0 ) //if rotated
2730 {
2731 switch(mode)
2732 {
2733 case 1:
2734 //transparent
2735 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2736 rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2737
2738 break;
2739
2740 case 2:
2741 //pivot?
2742 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
2743 //return an error, cannot both rotate and pivot
2744 break;
2745
2746 case 3:
2747 //pivot + trans
2748 //return an error, cannot both rotate and pivot
2749 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
2750 break;
2751
2752 case 4:
2753 //flip v
2754 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2755 rotate_sprite_v_flip(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2756 break;
2757
2758 case 5:
2759 //trans + v flip
2760 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2761 rotate_sprite_v_flip_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2762 break;
2763
2764 case 6:
2765 //pivot + v flip
2766 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
2767 //return an error, cannot both rotate and pivot
2768 break;
2769
2770 case 8:
2771 //flip h
2772 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
2773 //return an error, cannot both rotate and flip H
2774 break;
2775
2776 case 9:
2777 //trans + h flip
2778 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
2779 //return an error, cannot rotate and flip a trans sprite
2780 break;
2781
2782 case 10:
2783 //flip H and pivot
2784 //return error cannot pivot and h flip
2785 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
2786 break;
2787
2788 case 12:
2789 //vh flip
2790 //return an error, cannot rotate and VH flip a trans sprite
2791 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
2792 break;
2793
2794 case 13:
2795 //trans + vh flip
2796 //return an error, cannot rotate and VH flip a trans sprite
2797 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
2798 break;
2799
2800 case 14:
2801 //pivot and vh flip
2802 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
2803 //return error cannot both pivot and vh flip
2804 break;
2805
2806 case 16:
2807 //lit
2808 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2809 rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
2810 break;
2811
2812 case 18:
2813 //pivot, lit
2814 //return an error, cannot both rotate and pivot
2815 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
2816 break;
2817
2818 case 20:
2819 //lit + vflip
2820 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2821 rotate_sprite_v_flip_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
2822 break;
2823
2824 case 22:
2825 //Pivot, vflip, lit
2826 //return an error, cannot both rotate and pivot
2827 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
2828 break;
2829
2830 case 24:
2831 //lit + h flip
2832 //return an error, cannot both rotate and H flip
2833 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
2834 break;
2835
2836 case 26:
2837 //pivot + lit + hflip
2838 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
2839 //return error cannot pivot, lit, and flip
2840 break;
2841
2842 case 28:
2843 //lit + vh flip
2844 //return an error, cannot both rotate and VH flip
2845 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
2846 break;
2847
2848 case 32: //gouraud
2849 //Probably not wort supporting.
2850 //masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2851 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
2852 break;
2853
2854 case 0:
2855 //no effect.
2856 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2857 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2858 break;
2859
2860 default:
2861 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
2862
2863 }
2864 }
2865 } //end if stretched and masked
2866
2867 else //stretched, not masked
2868 {
2869 if ( rot == 0 ) //if not rotated
2870 {
2871 switch(mode) {
2872 case 1:
2873 //transparent
2874 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2875 draw_trans_sprite(bmp, subBmp, dx, dy);
2876 break;
2877
2878
2879 case 2:
2880 //pivot?
2881 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2882 pivot_sprite(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
2883 //Pivoting requires two more args
2884 break;
2885
2886 case 3:
2887 //pivot + trans
2888 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2889 pivot_sprite_trans(bmp, subBmp, dx,dy, cx, cy, degrees_to_fixed(rot));
2890 break;
2891
2892 case 4:
2893 //flip v
2894 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2895 draw_sprite_v_flip(bmp, subBmp, dx, dy);
2896 break;
2897
2898 case 5:
2899 //trans + v flip
2900 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2901 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
2902 break;
2903
2904 case 6:
2905 //pivot + v flip
2906 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2907 pivot_sprite_v_flip(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
2908 break;
2909
2910 case 8:
2911 //vlip h
2912 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2913 draw_sprite_h_flip(bmp, subBmp, dx, dy);
2914 break;
2915
2916 case 9:
2917 //trans + h flip
2918 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2919 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
2920 break;
2921
2922 case 10:
2923 //flip H and pivot
2924 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
2925 //return error cannot pivot and h flip
2926 break;
2927
2928 case 12:
2929 //vh flip
2930 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2931 draw_sprite_vh_flip(bmp, subBmp, dx, dy);
2932 break;
2933
2934 case 13:
2935 //trans + vh flip
2936 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2937 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
2938 break;
2939
2940 case 14:
2941 //pivot and vh flip
2942 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
2943 //return error cannot both pivot and vh flip
2944 break;
2945
2946 case 16:
2947 //lit
2948 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2949 draw_lit_sprite(bmp, subBmp, dx, dy, litcolour);
2950 break;
2951
2952 case 18:
2953 //pivot, lit
2954 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2955 pivot_sprite_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
2956 break;
2957
2958 case 20:
2959 //lit + v flip
2960 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2961 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
2962 break;
2963
2964 case 22:
2965 //Pivot, vflip, lit
2966 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2967 pivot_sprite_v_flip_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
2968 break;
2969
2970 case 24:
2971 //lit + h flip
2972 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2973 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
2974 break;
2975
2976 case 26:
2977 //pivot + lit + hflip
2978 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
2979 //return error cannot pivot, lit, and flip
2980 break;
2981
2982 case 28:
2983 //lit + vh flip
2984 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2985 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
2986 break;
2987
2988 case 32: //gouraud
2989 //Probably not wort supporting.
2990 //stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2991 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
2992 break;
2993
2994 case 0:
2995 //no effect
2996 stretch_blit(sourceBitmap, bmp, sx, sy, sw, sh, dx, dy, dw, dh);
2997 break;
2998
2999
3000 default:
3001 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
3002
3003
3004 }
3005 } //end if not rotated
3006
3007 if ( rot != 0 ) //if rotated
3008 {
3009 switch(mode)
3010 {
3011 case 1:
3012 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
3013 rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3014
3015 break;
3016
3017 case 2:
3018 //pivot?
3019 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3020 //return an error, cannot both rotate and pivot
3021 break;
3022
3023 case 3:
3024 //pivot + trans
3025 //return an error, cannot both rotate and pivot
3026 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3027 break;
3028
3029 case 4:
3030 //flip v
3031 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3032 rotate_sprite_v_flip(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3033 break;
3034
3035 case 5:
3036 //trans + v flip
3037 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3038 rotate_sprite_v_flip_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3039 break;
3040
3041 case 6:
3042 //pivot + v flip
3043 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3044 //return an error, cannot both rotate and pivot
3045 break;
3046
3047 case 8:
3048 //flip h
3049 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
3050 //return an error, cannot both rotate and flip H
3051 break;
3052
3053 case 9:
3054 //trans + h flip
3055 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
3056 //return an error, cannot rotate and flip a trans sprite
3057 break;
3058
3059 case 10:
3060 //flip H and pivot
3061 //return error cannot pivot and h flip
3062 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
3063 break;
3064
3065 case 12:
3066 //vh flip
3067 //return an error, cannot rotate and VH flip a trans sprite
3068 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
3069 break;
3070
3071 case 13:
3072 //trans + vh flip
3073 //return an error, cannot rotate and VH flip a trans sprite
3074 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
3075 break;
3076
3077 case 14:
3078 //pivot and vh flip
3079 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3080 //return error cannot both pivot and vh flip
3081 break;
3082
3083 case 16:
3084 //lit
3085 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
3086 rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
3087 break;
3088
3089 case 18:
3090 //pivot, lit
3091 //return an error, cannot both rotate and pivot
3092 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3093 break;
3094
3095 case 20:
3096 //lit + vflip
3097 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
3098 rotate_sprite_v_flip_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
3099 break;
3100
3101 case 22:
3102 //Pivot, vflip, lit
3103 //return an error, cannot both rotate and pivot
3104 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3105 break;
3106
3107 case 24:
3108 //lit + h flip
3109 //return an error, cannot both rotate and H flip
3110 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
3111 break;
3112
3113 case 26:
3114 //pivot + lit + hflip
3115 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
3116 //return error cannot pivot, lit, and flip
3117 break;
3118
3119 case 28:
3120 //lit + vh flip
3121 //return an error, cannot both rotate and VH flip
3122 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
3123 break;
3124
3125 case 32: //gouraud
3126 //Probably not wort supporting.
3127 //stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3128 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
3129 break;
3130
3131 case 0:
3132 //no effect.
3133 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3134 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3135 break;
3136
3137 default:
3138 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
3139
3140 }
3141 }
3142
3143 } //end if stretched, but not masked
3144 }
3145 else //not stretched
3146 {
3147
3148 if(masked) //if masked, but not stretched
3149 {
3150
3151 if ( rot == 0 ) //if not rotated
3152 {
3153 switch(mode)
3154 {
3155 case 1:
3156 //transparent
3157 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3158 draw_trans_sprite(bmp, subBmp, dx, dy);
3159 break;
3160
3161
3162 case 2:
3163 //pivot?
3164 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3165 pivot_sprite(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
3166 //Pivoting requires two more args
3167 break;
3168
3169 case 3:
3170 //pivot + trans
3171 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3172 pivot_sprite_trans(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
3173 break;
3174
3175 case 4:
3176 //flip v
3177 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3178 draw_sprite_v_flip(bmp, subBmp, dx, dy);
3179 break;
3180
3181 case 5:
3182 //trans + v flip
3183 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3184 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
3185 break;
3186
3187 case 6:
3188 //pivot + v flip
3189 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3190 pivot_sprite_v_flip(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
3191 break;
3192
3193 case 8:
3194 //vlip h
3195 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3196 draw_sprite_h_flip(bmp, subBmp, dx, dy);
3197 break;
3198
3199 case 9:
3200 //trans + h flip
3201 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3202 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
3203 break;
3204
3205 case 10:
3206 //flip H and pivot
3207 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
3208 //return error cannot pivot and h flip
3209 break;
3210
3211 case 12:
3212 //vh flip
3213 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3214 draw_sprite_vh_flip(bmp, subBmp, dx, dy);
3215 break;
3216
3217 case 13:
3218 //trans + vh flip
3219 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3220 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
3221 break;
3222
3223 case 14:
3224 //pivot and vh flip
3225 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
3226 //return error cannot both pivot and vh flip
3227 break;
3228
3229 case 16:
3230 //lit
3231 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3232 draw_lit_sprite(bmp, subBmp, dx, dy, litcolour);
3233 break;
3234
3235 case 18:
3236 //pivot, lit
3237 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3238 pivot_sprite_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
3239 break;
3240
3241 case 20:
3242 //lit + v flip
3243 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3244 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
3245 break;
3246
3247 case 22:
3248 //Pivot, vflip, lit
3249 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3250 pivot_sprite_v_flip_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
3251 break;
3252
3253 case 24:
3254 //lit + h flip
3255 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3256 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
3257 break;
3258
3259 case 26:
3260 //pivot + lit + hflip
3261 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
3262 //return error cannot pivot, lit, and flip
3263 break;
3264
3265 case 28:
3266 //lit + vh flip
3267 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3268 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
3269 break;
3270
3271 case 32: //gouraud
3272 //Probably not wort supporting.
3273 //stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3274 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
3275 break;
3276
3277 case 0:
3278 //no effect
3279 masked_blit(sourceBitmap, bmp, sx, sy, dx, dy, dw, dh);
3280 break;
3281
3282
3283 default:
3284 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
3285
3286
3287 }
3288 } //end if not rotated
3289
3290 if ( rot != 0 ) //if rotated
3291 {
3292 switch(mode)
3293 {
3294 case 1:
3295 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); //transparent
3296 rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3297
3298 break;
3299
3300 case 2:
3301 //pivot?
3302 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3303 //return an error, cannot both rotate and pivot
3304 break;
3305
3306 case 3:
3307 //pivot + trans
3308 //return an error, cannot both rotate and pivot
3309 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3310 break;
3311
3312 case 4:
3313 //flip v
3314 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3315 rotate_sprite_v_flip(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3316 break;
3317
3318 case 5:
3319 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); //trans + v flip
3320 rotate_sprite_v_flip_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3321 break;
3322
3323 case 6:
3324 //pivot + v flip
3325 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3326 //return an error, cannot both rotate and pivot
3327 break;
3328
3329 case 8:
3330 //flip h
3331 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
3332 //return an error, cannot both rotate and flip H
3333 break;
3334
3335 case 9:
3336 //trans + h flip
3337 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
3338 //return an error, cannot rotate and flip a trans sprite
3339 break;
3340
3341 case 10:
3342 //flip H and pivot
3343 //return error cannot pivot and h flip
3344 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
3345 break;
3346
3347 case 12:
3348 //vh flip
3349 //return an error, cannot rotate and VH flip a trans sprite
3350 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
3351 break;
3352
3353 case 13:
3354 //trans + vh flip
3355 //return an error, cannot rotate and VH flip a trans sprite
3356 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
3357 break;
3358
3359 case 14:
3360 //pivot and vh flip
3361 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3362 //return error cannot both pivot and vh flip
3363 break;
3364
3365 case 16:
3366 //lit
3367 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3368 rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
3369 break;
3370
3371 case 18:
3372 //pivot, lit
3373 //return an error, cannot both rotate and pivot
3374 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3375 break;
3376
3377 case 20:
3378 //lit + vflip
3379 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3380 rotate_sprite_v_flip_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
3381 break;
3382
3383 case 22:
3384 //Pivot, vflip, lit
3385 //return an error, cannot both rotate and pivot
3386 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3387 break;
3388
3389 case 24:
3390 //lit + h flip
3391 //return an error, cannot both rotate and H flip
3392 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
3393 break;
3394
3395 case 26:
3396 //pivot + lit + hflip
3397 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
3398 //return error cannot pivot, lit, and flip
3399 break;
3400
3401 case 28:
3402 //lit + vh flip
3403 //return an error, cannot both rotate and VH flip
3404 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
3405 break;
3406
3407 case 32: //gouraud
3408 //Probably not wort supporting.
3409 //stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3410 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
3411 break;
3412
3413 case 0:
3414 //no effect.
3415 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3416 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3417 break;
3418
3419 default:
3420 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
3421
3422 }
3423 } //end rtated, masked
3424 } //end if masked
3425
3426 else //not masked, and not stretched; just blit
3427 {
3428
3429 if ( rot == 0 ) //if not rotated
3430 {
3431 switch(mode)
3432 {
3433 case 1:
3434 //transparent
3435 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3436 draw_trans_sprite(bmp, subBmp, dx, dy);
3437 break;
3438
3439
3440 case 2:
3441 //pivot?
3442 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3443 pivot_sprite(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
3444 //Pivoting requires two more args
3445 break;
3446
3447 case 3:
3448 //pivot + trans
3449 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3450 pivot_sprite_trans(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
3451 break;
3452
3453 case 4:
3454 //flip v
3455 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3456 draw_sprite_v_flip(bmp, subBmp, dx, dy);
3457 break;
3458
3459 case 5:
3460 //trans + v flip
3461 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3462 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
3463 break;
3464
3465 case 6:
3466 //pivot + v flip
3467 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3468 pivot_sprite_v_flip(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
3469 break;
3470
3471 case 8:
3472 //vlip h
3473 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3474 draw_sprite_h_flip(bmp, subBmp, dx, dy);
3475 break;
3476
3477 case 9:
3478 //trans + h flip
3479 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3480 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
3481 break;
3482
3483 case 10:
3484 //flip H and pivot
3485 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
3486 //return error cannot pivot and h flip
3487 break;
3488
3489 case 12:
3490 //vh flip
3491 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3492 draw_sprite_vh_flip(bmp, subBmp, dx, dy);
3493 break;
3494
3495 case 13:
3496 //trans + vh flip
3497 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3498 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
3499 break;
3500
3501 case 14:
3502 //pivot and vh flip
3503 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
3504 //return error cannot both pivot and vh flip
3505 break;
3506
3507 case 16:
3508 //lit
3509 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3510 draw_lit_sprite(bmp, subBmp, dx, dy, litcolour);
3511 break;
3512
3513 case 18:
3514 //pivot, lit
3515 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3516 pivot_sprite_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
3517 break;
3518
3519 case 20:
3520 //lit + v flip
3521 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3522 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
3523 break;
3524
3525 case 22:
3526 //Pivot, vflip, lit
3527 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3528 pivot_sprite_v_flip_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
3529 break;
3530
3531 case 24:
3532 //lit + h flip
3533 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3534 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
3535 break;
3536
3537 case 26:
3538 //pivot + lit + hflip
3539 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
3540 //return error cannot pivot, lit, and flip
3541 break;
3542
3543 case 28:
3544 //lit + vh flip
3545 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3546 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
3547 break;
3548
3549 case 32: //gouraud
3550 //Probably not wort supporting.
3551 //blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3552 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
3553 break;
3554
3555 case 0:
3556 //no effect
3557 blit(sourceBitmap, bmp, sx, sy, dx, dy, dw, dh);
3558 break;
3559
3560
3561 default:
3562 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
3563
3564
3565 }
3566 } //end if not rotated
3567
3568 if ( rot != 0 ) //if rotated
3569 {
3570 switch(mode)
3571 {
3572 case 1:
3573 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);//transparent
3574 rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3575
3576 break;
3577
3578 case 2:
3579 //pivot?
3580 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3581 //return an error, cannot both rotate and pivot
3582 break;
3583
3584 case 3:
3585 //pivot + trans
3586 //return an error, cannot both rotate and pivot
3587 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3588 break;
3589
3590 case 4:
3591 //flip v
3592 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3593 rotate_sprite_v_flip(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3594 break;
3595
3596 case 5:
3597 //trans + v flip
3598 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3599 rotate_sprite_v_flip_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3600 break;
3601
3602 case 6:
3603 //pivot + v flip
3604 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3605 //return an error, cannot both rotate and pivot
3606 break;
3607
3608 case 8:
3609 //flip h
3610 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
3611 //return an error, cannot both rotate and flip H
3612 break;
3613
3614 case 9:
3615 //trans + h flip
3616 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
3617 //return an error, cannot rotate and flip a trans sprite
3618 break;
3619
3620 case 10:
3621 //flip H and pivot
3622 //return error cannot pivot and h flip
3623 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
3624 break;
3625
3626 case 12:
3627 //vh flip
3628 //return an error, cannot rotate and VH flip a trans sprite
3629 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
3630 break;
3631
3632 case 13:
3633 //trans + vh flip
3634 //return an error, cannot rotate and VH flip a trans sprite
3635 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
3636 break;
3637
3638 case 14:
3639 //pivot and vh flip
3640 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3641 //return error cannot both pivot and vh flip
3642 break;
3643
3644 case 16:
3645 //lit
3646 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3647 rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
3648 break;
3649
3650 case 18:
3651 //pivot, lit
3652 //return an error, cannot both rotate and pivot
3653 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3654 break;
3655
3656 case 20:
3657 //lit + vflip
3658 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3659 rotate_sprite_v_flip_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
3660 break;
3661
3662 case 22:
3663 //Pivot, vflip, lit
3664 //return an error, cannot both rotate and pivot
3665 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3666 break;
3667
3668 case 24:
3669 //lit + h flip
3670 //return an error, cannot both rotate and H flip
3671 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
3672 break;
3673
3674 case 26:
3675 //pivot + lit + hflip
3676 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
3677 //return error cannot pivot, lit, and flip
3678 break;
3679
3680 case 28:
3681 //lit + vh flip
3682 //return an error, cannot both rotate and VH flip
3683 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
3684 break;
3685
3686 case 32: //gouraud
3687 //Probably not wort supporting.
3688 //blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3689 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
3690 break;
3691
3692 case 0:
3693 //no effect.
3694 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3695 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3696 break;
3697
3698 default:
3699 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
3700
3701 }
3702 } //end if rotated
3703 } //end if not masked
3704 } //end if not stretched
3705
3706 //cleanup
3707 if(subBmp)
3708 {
3709 script_drawing_commands.ReleaseSubBitmap(subBmp); //purge the temporary bitmap.
3710 }
3711 }
3712
3713
3714 void do_drawquad3dr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
3715 {
3716 //sdci[1]=layer
3717 //sdci[2]=pos[12]
3718 //sdci[3]=uv[8]
3719 //sdci[4]=color[4]
3720 //sdci[5]=size[2]
3721 //sdci[6]=flip
3722 //sdci[7]=tile/combo
3723 //sdci[8]=polytype
3724
3725 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
3726
3727 if(!v_ptr)
3728 {
3729 al_trace("Quad3d: Vector pointer is null! Internal error. \n");
3730 return;
3731 }
3732
3733 std::vector<int32_t> &v = *v_ptr;
3734
3735 if(v.empty())
3736 return;
3737
3738 int32_t* pos = &v[0];
3739 int32_t* uv = &v[12];
3740 int32_t* col = &v[20];
3741 int32_t* size = &v[24];
3742
3743 int32_t w = size[0]; //magic numerical constants... yuck.
3744 int32_t h = size[1];
3745 int32_t flip = (sdci[6]/10000)&3;
3746 int32_t tile = sdci[7]/10000;
3747 int32_t polytype = sdci[8]/10000;
3748
3749 polytype = vbound(polytype, 0, 14);
3750
3751 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
3752 {
3753 Z_message("Quad3d() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
3754 return; //non power of two error
3755 }
3756
3757 int32_t tex_width = w*16;
3758 int32_t tex_height = h*16;
3759
3760 bool mustDestroyBmp = false;
3761 BITMAP *tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
3762
3763 if(!tex)
3764 {
3765 mustDestroyBmp = true;
3766 tex = create_bitmap_ex(8, tex_width, tex_height);
3767 clear_bitmap(tex);
3768 }
3769
3770 if(tile > 0) // TILE
3771 {
3772 TileHelper::OverTile(tex, tile, 0, 0, w, h, col[0], flip);
3773 }
3774 else // COMBO
3775 {
3776 const newcombo & c = combobuf[ vbound(abs(tile), 0, 0xffff) ];
3777 const int32_t tiletodraw = combo_tile(c, 0, 0);
3778 flip = flip ^ c.flip;
3779
3780 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, col[0], flip);
3781 }
3782
3783 V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] };
3784 V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] };
3785 V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] };
3786 V3D_f V4 = { static_cast<float>(pos[9]+xoffset), static_cast<float>(pos[10]+yoffset), static_cast<float>(pos[11]), static_cast<float>(uv[6]), static_cast<float>(uv[7]), col[3] };
3787
3788 quad3d_f(bmp, polytype, tex, &V1, &V2, &V3, &V4);
3789
3790 if(mustDestroyBmp)
3791 destroy_bitmap(tex);
3792
3793 }
3794
3795
3796
3797 void do_drawtriangle3dr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
3798 {
3799 //sdci[1]=layer
3800 //sdci[2]=pos[9]
3801 //sdci[3]=uv[6]
3802 //sdci[4]=color[3]
3803 //sdci[5]=size[2]
3804 //sdci[6]=flip
3805 //sdci[7]=tile/combo
3806 //sdci[8]=polytype
3807
3808 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
3809
3810 if(!v_ptr)
3811 {
3812 al_trace("Triange3d: Vector pointer is null! Internal error. \n");
3813 return;
3814 }
3815
3816 std::vector<int32_t> &v = *v_ptr;
3817
3818 if(v.empty())
3819 return;
3820
3821 int32_t* pos = &v[0];
3822 int32_t* uv = &v[9];
3823 int32_t* col = &v[15];
3824 int32_t* size = &v[18];
3825
3826 int32_t w = size[0]; //magic numerical constants... yuck.
3827 int32_t h = size[1];
3828 int32_t flip = (sdci[6]/10000)&3;
3829 int32_t tile = sdci[7]/10000;
3830 int32_t polytype = sdci[8]/10000;
3831
3832 polytype = vbound(polytype, 0, 14);
3833
3834 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
3835 {
3836 Z_message("Triangle3d() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
3837 return; //non power of two error
3838 }
3839
3840 int32_t tex_width = w*16;
3841 int32_t tex_height = h*16;
3842
3843 bool mustDestroyBmp = false;
3844 BITMAP *tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
3845
3846 if(!tex)
3847 {
3848 mustDestroyBmp = true;
3849 tex = create_bitmap_ex(8, tex_width, tex_height);
3850 clear_bitmap(tex);
3851 }
3852
3853 if(tile > 0) // TILE
3854 {
3855 TileHelper::OverTile(tex, tile, 0, 0, w, h, col[0], flip);
3856 }
3857 else // COMBO
3858 {
3859 const newcombo & c = combobuf[ vbound(abs(tile), 0, 0xffff) ];
3860 const int32_t tiletodraw = combo_tile(c, 0, 0);
3861 flip = flip ^ c.flip;
3862
3863 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, col[0], flip);
3864 }
3865
3866 V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] };
3867 V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] };
3868 V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] };
3869
3870 triangle3d_f(bmp, polytype, tex, &V1, &V2, &V3);
3871
3872 if(mustDestroyBmp)
3873 destroy_bitmap(tex);
3874
3875 }
3876
3877 7818 void bmp_do_rectr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
3878 {
3879 //Z_scripterrlog("rect sdci[13] is: %d\n", sdci[13]);
3880 //sdci[1]=layer
3881 //sdci[2]=x
3882 //sdci[3]=y
3883 //sdci[4]=x2
3884 //sdci[5]=y2
3885 //sdci[6]=color
3886 //sdci[7]=scale factor
3887 //sdci[8]=rotation anchor x
3888 //sdci[9]=rotation anchor y
3889 //sdci[10]=rotation angle
3890 //sdci[11]=fill
3891 //sdci[12]=opacity
3892 //sdci[17] Bitmap Pointer
3893
1/2
✓ Branch 0 taken 7818 times.
✗ Branch 1 not taken.
7818 if(sdci[7]==0) //scale
3894 {
3895 return;
3896 }
3897
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7818 times.
7818 if ( sdci[17] <= 0 )
3898 {
3899 Z_scripterrlog("bitmap->Rectangle() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
3900 return;
3901 }
3902 7818 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
3903
1/2
✓ Branch 0 taken 7818 times.
✗ Branch 1 not taken.
7818 if ( refbmp == NULL ) return;
3904
3905
2/4
✓ Branch 0 taken 7818 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7818 times.
7818 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
3906
3907 7818 int32_t x1=sdci[2]/10000;
3908 7818 int32_t y1=sdci[3]/10000;
3909 7818 int32_t x2=sdci[4]/10000;
3910 7818 int32_t y2=sdci[5]/10000;
3911
3912
3913
2/2
✓ Branch 0 taken 7814 times.
✓ Branch 1 taken 4 times.
7818 if(x1>x2)
3914 {
3915 4 zc_swap(x1,x2);
3916 4 }
3917
3918
2/2
✓ Branch 0 taken 7814 times.
✓ Branch 1 taken 4 times.
7818 if(y1>y2)
3919 {
3920 4 zc_swap(y1,y2);
3921 4 }
3922
3923
1/2
✓ Branch 0 taken 7818 times.
✗ Branch 1 not taken.
7818 if(sdci[7] != 10000)
3924 {
3925 int32_t w=x2-x1+1;
3926 int32_t h=y2-y1+1;
3927 int32_t w2=(w*sdci[7])/10000;
3928 int32_t h2=(h*sdci[7])/10000;
3929 x1=x1-((w2-w)/2);
3930 x2=x2+((w2-w)/2);
3931 y1=y1-((h2-h)/2);
3932 y2=y2+((h2-h)/2);
3933 }
3934
3935 7818 int32_t color=sdci[6]/10000;
3936
3937
2/2
✓ Branch 0 taken 7690 times.
✓ Branch 1 taken 128 times.
7818 if(sdci[12]/10000<=127) //translucent
3938 {
3939 128 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
3940 128 }
3941
3942
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 7722 times.
7818 if(sdci[10]==0) //no rotation
3943 {
3944
2/2
✓ Branch 0 taken 7710 times.
✓ Branch 1 taken 12 times.
7722 if(sdci[11]) //filled
3945 {
3946 7710 rectfill(refbmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
3947 7710 }
3948 else //outline
3949 {
3950 12 rect(refbmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
3951 }
3952 7722 }
3953 else //rotate
3954 {
3955 int32_t xy[16];
3956 96 int32_t rx=sdci[8]/10000;
3957 96 int32_t ry=sdci[9]/10000;
3958 96 fixed ra1=itofix(sdci[10]%10000)/10000;
3959 96 fixed ra2=itofix(sdci[10]/10000);
3960 96 fixed ra=ra1+ra2;
3961 96 ra = (ra/360)*256;
3962
3963 96 fixed fcosa = fixcos(ra);
3964 96 fixed fsina = fixsin(ra);
3965
3966 96 xy[ 0]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y1 - ry))); //x1
3967 96 xy[ 1]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y1 - ry))); //y1
3968 96 xy[ 2]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y1 - ry))); //x2
3969 96 xy[ 3]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y1 - ry))); //y1
3970 96 xy[ 4]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y2 - ry))); //x2
3971 96 xy[ 5]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y2 - ry))); //y2
3972 96 xy[ 6]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y2 - ry))); //x1
3973 96 xy[ 7]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y2 - ry))); //y2
3974 96 xy[ 8]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y1 - ry + 1))); //x1
3975 96 xy[ 9]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y1 - ry + 1))); //y1
3976 96 xy[10]=xoffset+rx + fixtoi((fcosa * (x2 - rx - 1) - fsina * (y1 - ry))); //x2
3977 96 xy[11]=yoffset+ry + fixtoi((fsina * (x2 - rx - 1) + fcosa * (y1 - ry))); //y1
3978 96 xy[12]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y2 - ry - 1))); //x2
3979 96 xy[13]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y2 - ry - 1))); //y2
3980 96 xy[14]=xoffset+rx + fixtoi((fcosa * (x1 - rx + 1) - fsina * (y2 - ry))); //x1
3981 96 xy[15]=yoffset+ry + fixtoi((fsina * (x1 - rx + 1) + fcosa * (y2 - ry))); //y2
3982
3983
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(sdci[11]) //filled
3984 {
3985 96 polygon(refbmp, 4, xy, color);
3986 96 }
3987 else //outline
3988 {
3989 line(refbmp, xy[0], xy[1], xy[10], xy[11], color);
3990 line(refbmp, xy[2], xy[3], xy[12], xy[13], color);
3991 line(refbmp, xy[4], xy[5], xy[14], xy[15], color);
3992 line(refbmp, xy[6], xy[7], xy[ 8], xy[ 9], color);
3993 }
3994 }
3995
3996 7818 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
3997 7818 }
3998
3999 void bmp_do_framer(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4000 {
4001 //sdci[1]=layer
4002 //sdci[2]=x
4003 //sdci[3]=y
4004 //sdci[4]=tile
4005 //sdci[5]=cset
4006 //sdci[6]=width
4007 //sdci[7]=height
4008 //sdci[8]=overlay
4009 //sdci[9]=opacity
4010
4011 if ( sdci[17] <= 0 )
4012 {
4013 Z_scripterrlog("bitmap->DrawFrame() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
4014 return;
4015 }
4016 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
4017 if ( refbmp == NULL ) return;
4018
4019 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
4020
4021 int32_t x=sdci[2]/10000;
4022 int32_t y=sdci[3]/10000;
4023
4024 int32_t tile=sdci[4]/10000;
4025 int32_t cs=sdci[5]/10000;
4026 int32_t w=sdci[6]/10000;
4027 int32_t h=sdci[7]/10000;
4028 bool overlay=sdci[8];
4029 bool trans=(sdci[9]/10000<=127);
4030
4031 frame2x2(refbmp, &QMisc, x + xoffset, y + yoffset, tile, cs, w, h, 0, overlay, trans);
4032 }
4033
4034
4035 1480 void bmp_do_circler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4036 {
4037 //sdci[1]=layer
4038 //sdci[2]=x
4039 //sdci[3]=y
4040 //sdci[4]=radius
4041 //sdci[5]=color
4042 //sdci[6]=scale factor
4043 //sdci[7]=rotation anchor x
4044 //sdci[8]=rotation anchor y
4045 //sdci[9]=rotation angle
4046 //sdci[10]=fill
4047 //sdci[11]=opacity
4048 //sdci[17] Bitmap Pointer
4049
1/2
✓ Branch 0 taken 1480 times.
✗ Branch 1 not taken.
1480 if(sdci[6]==0) //scale
4050 {
4051 return;
4052 }
4053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1480 times.
1480 if ( sdci[17] <= 0 )
4054 {
4055 Z_scripterrlog("bitmap->Circle() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
4056 return;
4057 }
4058 1480 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
4059
1/2
✓ Branch 0 taken 1480 times.
✗ Branch 1 not taken.
1480 if ( refbmp == NULL ) return;
4060
4061
2/4
✓ Branch 0 taken 1480 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1480 times.
1480 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
4062
4063 1480 int32_t x1=sdci[2]/10000;
4064 1480 int32_t y1=sdci[3]/10000;
4065 1480 qword r=sdci[4];
4066
4067
1/2
✓ Branch 0 taken 1480 times.
✗ Branch 1 not taken.
1480 if(sdci[6] != 10000)
4068 {
4069 r*=sdci[6];
4070 r/=10000;
4071 }
4072
4073 1480 r/=10000;
4074 1480 int32_t color=sdci[5]/10000;
4075
4076
1/2
✓ Branch 0 taken 1480 times.
✗ Branch 1 not taken.
1480 if(sdci[11]/10000<=127) //translucent
4077 {
4078 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
4079 }
4080
4081
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1480 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1480 if(sdci[9]!=0&&(sdci[2]!=sdci[7]||sdci[3]!=sdci[8])) //rotation
4082 {
4083 int32_t xy[2];
4084 int32_t rx=sdci[7]/10000;
4085 int32_t ry=sdci[8]/10000;
4086 fixed ra1=itofix(sdci[9]%10000)/10000;
4087 fixed ra2=itofix(sdci[9]/10000);
4088 fixed ra=ra1+ra2;
4089 ra = (ra/360)*256;
4090
4091 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
4092 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
4093 x1=xy[0];
4094 y1=xy[1];
4095 }
4096
4097
1/2
✓ Branch 0 taken 1480 times.
✗ Branch 1 not taken.
1480 if(sdci[10]) //filled
4098 {
4099 1480 circlefill(refbmp, x1+xoffset, y1+yoffset, r, color);
4100 1480 }
4101 else //outline
4102 {
4103 circle(refbmp, x1+xoffset, y1+yoffset, r, color);
4104 }
4105
4106 1480 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
4107 1480 }
4108
4109
4110 void bmp_do_arcr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4111 {
4112 //sdci[1]=layer
4113 //sdci[2]=x
4114 //sdci[3]=y
4115 //sdci[4]=radius
4116 //sdci[5]=start angle
4117 //sdci[6]=end angle
4118 //sdci[7]=color
4119 //sdci[8]=scale factor
4120 //sdci[9]=rotation anchor x
4121 //sdci[10]=rotation anchor y
4122 //sdci[11]=rotation angle
4123 //sdci[12]=closed
4124 //sdci[13]=fill
4125 //sdci[14]=opacity
4126 //sdci[17] Bitmap Pointer
4127
4128 if(sdci[8]==0) //scale
4129 {
4130 return;
4131 }
4132 if ( sdci[17] <= 0 )
4133 {
4134 Z_scripterrlog("bitmap->Arc() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
4135 return;
4136 }
4137 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
4138 if ( refbmp == NULL ) return;
4139
4140 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
4141
4142 int32_t cx=sdci[2]/10000;
4143 int32_t cy=sdci[3]/10000;
4144 qword r=sdci[4];
4145
4146 if(sdci[8] != 10000)
4147 {
4148 r*=sdci[8];
4149 r/=10000;
4150 }
4151
4152 r/=10000;
4153
4154 int32_t color=sdci[7]/10000;
4155
4156 fixed ra1=itofix(sdci[11]%10000)/10000;
4157 fixed ra2=itofix(sdci[11]/10000);
4158 fixed ra=ra1+ra2;
4159 ra = (ra/360)*256;
4160
4161
4162 fixed a1=itofix(sdci[5]%10000)/10000;
4163 fixed a2=itofix(sdci[5]/10000);
4164 fixed sa=a1+a2;
4165 sa = (sa/360)*256;
4166
4167 a1=itofix(sdci[6]%10000)/10000;
4168 a2=itofix(sdci[6]/10000);
4169 fixed ea=a1+a2;
4170 ea = (ea/360)*256;
4171
4172 if(sdci[11]!=0) //rotation
4173 {
4174 int32_t rx=sdci[9]/10000;
4175 int32_t ry=sdci[10]/10000;
4176
4177 cx=rx + fixtoi((fixcos(ra) * (cx - rx) - fixsin(ra) * (cy - ry))); //x1
4178 cy=ry + fixtoi((fixsin(ra) * (cx - rx) + fixcos(ra) * (cy - ry))); //y1
4179 ea-=ra;
4180 sa-=ra;
4181 }
4182
4183 int32_t fx=cx+fixtoi(fixcos(-(ea+sa)/2)*r/2);
4184 int32_t fy=cy+fixtoi(fixsin(-(ea+sa)/2)*r/2);
4185
4186 if(sdci[12]) //closed
4187 {
4188 if(sdci[13]) //filled
4189 {
4190 clear_bitmap(prim_bmp);
4191 arc(prim_bmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color);
4192 line(prim_bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-sa)*r), cy+yoffset+fixtoi(fixsin(-sa)*r), color);
4193 line(prim_bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-ea)*r), cy+yoffset+fixtoi(fixsin(-ea)*r), color);
4194 int fillx = zc_max(0,fx)+xoffset;
4195 int filly = zc_max(0,fy)+yoffset;
4196 zprint2("bitmap->Arc fill at prim_bmp (%d,%d) - 512x512\n", fillx, filly);
4197 floodfill(prim_bmp, fillx, filly, color);
4198
4199 if(sdci[14]/10000<=127) //translucent
4200 {
4201 draw_trans_sprite(refbmp, prim_bmp, 0,0);
4202 }
4203 else
4204 {
4205 draw_sprite(refbmp, prim_bmp, 0,0);
4206 }
4207 }
4208 else
4209 {
4210 arc(refbmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color);
4211 line(refbmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-sa)*r), cy+yoffset+fixtoi(fixsin(-sa)*r), color);
4212 line(refbmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-ea)*r), cy+yoffset+fixtoi(fixsin(-ea)*r), color);
4213 }
4214 }
4215 else
4216 {
4217 if(sdci[14]/10000<=127) //translucent
4218 {
4219 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
4220 }
4221
4222 arc(refbmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color);
4223 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
4224 }
4225 }
4226
4227
4228 502 void bmp_do_ellipser(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4229 {
4230 //sdci[1]=layer
4231 //sdci[2]=x
4232 //sdci[3]=y
4233 //sdci[4]=radiusx
4234 //sdci[5]=radiusy
4235 //sdci[6]=color
4236 //sdci[7]=scale factor
4237 //sdci[8]=rotation anchor x
4238 //sdci[9]=rotation anchor y
4239 //sdci[10]=rotation angle
4240 //sdci[11]=fill
4241 //sdci[12]=opacity
4242 //sdci[17] Bitmap Pointer
4243
4244
1/2
✓ Branch 0 taken 502 times.
✗ Branch 1 not taken.
502 if(sdci[7]==0) //scale
4245 {
4246 return;
4247 }
4248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 502 times.
502 if ( sdci[17] <= 0 )
4249 {
4250 Z_scripterrlog("bitmap->Ellipse() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
4251 return;
4252 }
4253 502 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
4254
1/2
✓ Branch 0 taken 502 times.
✗ Branch 1 not taken.
502 if ( refbmp == NULL ) return;
4255
4256 502 int32_t x1=sdci[2]/10000;
4257 502 int32_t y1=sdci[3]/10000;
4258 502 int32_t radx=sdci[4]/10000;
4259 502 radx*=sdci[7]/10000;
4260 502 int32_t rady=sdci[5]/10000;
4261 502 rady*=sdci[7]/10000;
4262 502 int32_t color=sdci[6]/10000;
4263 502 float rotation = sdci[10]/10000;
4264
4265 502 int32_t rx=sdci[8]/10000;
4266 502 int32_t ry=sdci[9]/10000;
4267 502 fixed ra1=itofix(sdci[10]%10000)/10000;
4268 502 fixed ra2=itofix(sdci[10]/10000);
4269 502 fixed ra=ra1+ra2;
4270 502 ra = (ra/360)*256;
4271
4272
2/4
✓ Branch 0 taken 502 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 502 times.
✗ Branch 3 not taken.
502 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
4273
4274 int32_t xy[2];
4275 502 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
4276 502 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
4277 502 x1=xy[0];
4278 502 y1=xy[1];
4279
4280
6/8
✓ Branch 0 taken 498 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 494 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 494 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 494 times.
502 if(radx<1||rady<1||radx>255||rady>255) return;
4281
4282 494 BITMAP* bitty = script_drawing_commands.AquireSubBitmap(radx*2+1, rady*2+1);
4283
4284
2/4
✓ Branch 0 taken 494 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 494 times.
494 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
4285
4286
1/2
✓ Branch 0 taken 494 times.
✗ Branch 1 not taken.
494 if(sdci[11]) //filled
4287 {
4288
4289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 494 times.
494 if(sdci[12]/10000<128) //translucent
4290 {
4291 clear_bitmap(prim_bmp);
4292 ellipsefill(bitty, radx, rady, radx, rady, color==0?255:color);
4293 rotate_sprite(prim_bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
4294 draw_trans_sprite(refbmp, prim_bmp, 0, 0);
4295 }
4296 else // no opacity
4297 {
4298
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 62 times.
494 ellipsefill(bitty, radx, rady, radx, rady, color==0?255:color);
4299 494 rotate_sprite(refbmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
4300 }
4301 494 }
4302 else //not filled
4303 {
4304 if(sdci[12]/10000<128) //translucent
4305 {
4306 clear_bitmap(prim_bmp);
4307 ellipse(bitty, radx, rady, radx, rady, color==0?255:color);
4308 rotate_sprite(prim_bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
4309 draw_trans_sprite(refbmp, prim_bmp, 0, 0);
4310 }
4311 else // no opacity
4312 {
4313 ellipse(bitty, radx, rady, radx, rady, color==0?255:color);
4314 rotate_sprite(refbmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
4315 }
4316 }
4317
4318 // Since 0 is the transparent color, the stuff above will fail if the ellipse color is also 0.
4319 // Instead, it uses color 255 and replaces it afterward. That'll also screw up color 255 around
4320 // the ellipse, but it shouldn't be used anyway.
4321
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 62 times.
494 if(color==0)
4322 {
4323 // This is very slow, so check the smallest possible square
4324
3/6
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
✓ Branch 4 taken 62 times.
✗ Branch 5 not taken.
62 int32_t endx=zc_min(bmp->w-1, x1+zc_max(radx, rady));
4325
3/6
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
✓ Branch 4 taken 62 times.
✗ Branch 5 not taken.
62 int32_t endy=zc_min(bmp->h-1, y1+zc_max(radx, rady));
4326
4327
6/8
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4430 times.
✓ Branch 7 taken 62 times.
4492 for(int32_t y=zc_max(0, y1-zc_max(radx, rady)); y<=endy; y++)
4328
6/8
✓ Branch 0 taken 4430 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3052 times.
✓ Branch 3 taken 1378 times.
✓ Branch 4 taken 1378 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 467774 times.
✓ Branch 7 taken 4430 times.
472204 for(int32_t x=zc_max(0, x1-zc_max(radx, rady)); x<=endx; x++)
4329
2/2
✓ Branch 0 taken 238992 times.
✓ Branch 1 taken 228782 times.
696556 if(getpixel(refbmp, x, y)==255)
4330 233212 putpixel(refbmp, x, y, 0);
4331 62 }
4332
4333 494 script_drawing_commands.ReleaseSubBitmap(bitty);
4334 502 }
4335
4336
4337 144 void bmp_do_liner(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4338 {
4339 //sdci[1]=layer
4340 //sdci[2]=x
4341 //sdci[3]=y
4342 //sdci[4]=x2
4343 //sdci[5]=y2
4344 //sdci[6]=color
4345 //sdci[7]=scale factor
4346 //sdci[8]=rotation anchor x
4347 //sdci[9]=rotation anchor y
4348 //sdci[10]=rotation angle
4349 //sdci[11]=opacity
4350 //sdci[17] Bitmap Pointer
4351
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(sdci[7]==0) //scale
4352 {
4353 return;
4354 }
4355
4356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if ( sdci[17] <= 0 )
4357 {
4358 Z_scripterrlog("bitmap->Line() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
4359 return;
4360 }
4361
4362 144 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
4363
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if ( refbmp == NULL ) return;
4364
4365 144 int32_t x1=sdci[2]/10000;
4366 144 int32_t y1=sdci[3]/10000;
4367 144 int32_t x2=sdci[4]/10000;
4368 144 int32_t y2=sdci[5]/10000;
4369
4370
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(sdci[7] != 10000)
4371 {
4372 int32_t w=x2-x1+1;
4373 int32_t h=y2-y1+1;
4374 int32_t w2=int32_t(w*((double)sdci[7]/10000.0));
4375 int32_t h2=int32_t(h*((double)sdci[7]/10000.0));
4376 x1=x1-((w2-w)/2);
4377 x2=x2+((w2-w)/2);
4378 y1=y1-((h2-h)/2);
4379 y2=y2+((h2-h)/2);
4380 }
4381
4382 144 int32_t color=sdci[6]/10000;
4383
4384
2/4
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 144 times.
144 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
4385
4386
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(sdci[11]/10000<=127) //translucent
4387 {
4388 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
4389 }
4390
4391
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(sdci[10]!=0) //rotation
4392 {
4393 int32_t xy[4];
4394 int32_t rx=sdci[8]/10000;
4395 int32_t ry=sdci[9]/10000;
4396 fixed ra1=itofix(sdci[10]%10000)/10000;
4397 fixed ra2=itofix(sdci[10]/10000);
4398 fixed ra=ra1+ra2;
4399
4400 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
4401 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
4402 xy[ 2]=rx + fixtoi((fixcos(ra) * (x2 - rx) - fixsin(ra) * (y2 - ry))); //x2
4403 xy[ 3]=ry + fixtoi((fixsin(ra) * (x2 - rx) + fixcos(ra) * (y2 - ry))); //y2
4404 x1=xy[0];
4405 y1=xy[1];
4406 x2=xy[2];
4407 y2=xy[3];
4408 }
4409
4410 144 line(refbmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
4411 144 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
4412 144 }
4413
4414
4415 void bmp_do_spliner(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4416 {
4417 /* layer, x1, y1, x2, y2, x3, y3, x4, y4, color, opacity */
4418 //sdci[17] Bitmap Pointer
4419
4420 int32_t points[8] = { xoffset + (sdci[2]/10000), yoffset + (sdci[3]/10000),
4421 xoffset + (sdci[4]/10000), yoffset + (sdci[5]/10000),
4422 xoffset + (sdci[6]/10000), yoffset + (sdci[7]/10000),
4423 xoffset + (sdci[8]/10000), yoffset + (sdci[9]/10000)
4424 };
4425
4426 if(sdci[11]/10000 < 128) //translucent
4427 {
4428 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
4429 }
4430
4431 if ( sdci[17] <= 0 )
4432 {
4433 Z_scripterrlog("bitmap->Spline() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
4434 return;
4435 }
4436
4437 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
4438 if ( refbmp == NULL ) return;
4439
4440 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
4441
4442 spline(refbmp, points, sdci[10]/10000);
4443
4444 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
4445 }
4446
4447
4448 80910 void bmp_do_putpixelr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4449 {
4450 //sdci[1]=layer
4451 //sdci[2]=x
4452 //sdci[3]=y
4453 //sdci[4]=color
4454 //sdci[5]=rotation anchor x
4455 //sdci[6]=rotation anchor y
4456 //sdci[7]=rotation angle
4457 //sdci[8]=opacity
4458 //sdci[17] Bitmap Pointer
4459 80910 int32_t x1=sdci[2]/10000;
4460 80910 int32_t y1=sdci[3]/10000;
4461 80910 int32_t color=sdci[4]/10000;
4462
4463
1/2
✓ Branch 0 taken 80910 times.
✗ Branch 1 not taken.
80910 if(sdci[8]/10000<=127) //translucent
4464 {
4465 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
4466 }
4467
4468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80910 times.
80910 if ( sdci[17] <= 0 )
4469 {
4470 Z_scripterrlog("bitmap->PutPixel() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
4471 return;
4472 }
4473
4474 80910 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
4475
1/2
✓ Branch 0 taken 80910 times.
✗ Branch 1 not taken.
80910 if ( refbmp == NULL ) return;
4476
4477
2/4
✓ Branch 0 taken 80910 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80910 times.
✗ Branch 3 not taken.
80910 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
4478
4479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80910 times.
80910 if(sdci[7]!=0) //rotation
4480 {
4481 int32_t xy[2];
4482 int32_t rx=sdci[5]/10000;
4483 int32_t ry=sdci[6]/10000;
4484 fixed ra1=itofix(sdci[7]%10000)/10000;
4485 fixed ra2=itofix(sdci[7]/10000);
4486 fixed ra=ra1+ra2;
4487
4488 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
4489 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
4490 x1=xy[0];
4491 y1=xy[1];
4492 }
4493
4494 80910 putpixel(refbmp, x1+xoffset, y1+yoffset, color);
4495 80910 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
4496 80910 }
4497
4498
4499 59428 void bmp_do_drawtiler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4500 {
4501 //sdci[1]=layer
4502 //sdci[2]=x
4503 //sdci[3]=y
4504 //sdci[4]=tile
4505 //sdci[5]=tile width
4506 //sdci[6]=tile height
4507 //sdci[7]=color (cset)
4508 //sdci[8]=scale x
4509 //sdci[9]=scale y
4510 //sdci[10]=rotation anchor x
4511 //sdci[11]=rotation anchor y
4512 //sdci[12]=rotation angle
4513 //sdci[13]=flip
4514 //sdci[14]=transparency
4515 //sdci[15]=opacity
4516 //sdci[17] Bitmap Pointer
4517
4518 59428 int32_t w = sdci[5]/10000;
4519 59428 int32_t h = sdci[6]/10000;
4520
4521
4/8
✓ Branch 0 taken 59428 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59428 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 59428 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 59428 times.
59428 if(w < 1 || h < 1 || h > 20 || w > 20)
4522 {
4523 return;
4524 }
4525
4526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59428 times.
59428 if ( sdci[17] <= 0 )
4527 {
4528 Z_scripterrlog("bitmap->DrawTile() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
4529 return;
4530 }
4531
4532 59428 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
4533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59428 times.
59428 if ( refbmp == NULL ) return;
4534
4535 59428 int32_t xscale=sdci[8]/10000;
4536 59428 int32_t yscale=sdci[9]/10000;
4537 59428 int32_t rx = sdci[10]/10000;
4538 59428 int32_t ry = sdci[11]/10000;
4539 59428 float rotation=sdci[12]/10000;
4540 59428 int32_t flip=(sdci[13]/10000)&3;
4541 59428 bool transparency=sdci[14]!=0;
4542 59428 int32_t opacity=sdci[15]/10000;
4543 59428 int32_t color=sdci[7]/10000;
4544
4545 59428 int32_t x1=sdci[2]/10000;
4546 59428 int32_t y1=sdci[3]/10000;
4547
4548
4549 //don't scale if it's not safe to do so
4550 59428 bool canscale = true;
4551
4552
2/4
✓ Branch 0 taken 59428 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 59428 times.
59428 if(xscale==0||yscale==0)
4553 {
4554 return;
4555 }
4556
4557
3/4
✓ Branch 0 taken 906 times.
✓ Branch 1 taken 58522 times.
✓ Branch 2 taken 906 times.
✗ Branch 3 not taken.
59428 if(xscale<0||yscale<0)
4558 58522 canscale = false; //default size
4559
4560
2/4
✓ Branch 0 taken 59428 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 59428 times.
59428 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
4561
4562
4/4
✓ Branch 0 taken 906 times.
✓ Branch 1 taken 58522 times.
✓ Branch 2 taken 4608 times.
✓ Branch 3 taken 53914 times.
59428 if((xscale>0 && yscale>0) || rotation) //scaled or rotated
4563 {
4564 5514 BITMAP* pbitty = script_drawing_commands.AquireSubBitmap(w*16, h*16);
4565
4566
1/2
✓ Branch 0 taken 5514 times.
✗ Branch 1 not taken.
5514 if(transparency) //transparency
4567 {
4568 5514 TileHelper::OverTile(pbitty, (sdci[4]/10000), 0, 0, w, h, color, flip);
4569 5514 }
4570 else //no transparency
4571 {
4572 TileHelper::OldPutTile(pbitty, (sdci[4]/10000), 0, 0, w, h, color, flip);
4573 }
4574
4575
2/2
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 906 times.
5514 if(rotation != 0)
4576 {
4577 //low negative values indicate no anchor-point rotation
4578
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4608 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4608 if(rx>-777||ry>-777)
4579 {
4580 int32_t xy[2];
4581 4608 fixed ra1=itofix(sdci[12]%10000)/10000;
4582 4608 fixed ra2=itofix(sdci[12]/10000);
4583 4608 fixed ra=ra1+ra2;
4584 4608 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
4585 4608 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
4586 4608 x1=xy[0];
4587 4608 y1=xy[1];
4588 4608 }
4589
4590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4608 times.
4608 if(canscale) //scale first
4591 {
4592 //damnit all, .. fixme.
4593 BITMAP* tempbit = create_bitmap_ex(8, xscale>512?512:xscale, yscale>512?512:yscale);
4594 clear_bitmap(tempbit);
4595
4596 stretch_sprite(tempbit, pbitty, 0, 0, xscale, yscale);
4597
4598 if(opacity < 128)
4599 {
4600 clear_bitmap(prim_bmp);
4601 rotate_sprite(prim_bmp, tempbit, 0, 0, degrees_to_fixed(rotation));
4602 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
4603 }
4604 else
4605 {
4606 rotate_sprite(refbmp, tempbit, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
4607 }
4608
4609 destroy_bitmap(tempbit);
4610 }
4611 else //no scale
4612 {
4613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4608 times.
4608 if(opacity < 128)
4614 {
4615 clear_bitmap(prim_bmp);
4616 rotate_sprite(prim_bmp, pbitty, 0, 0, degrees_to_fixed(rotation));
4617 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4618 }
4619 else
4620 {
4621 4608 rotate_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
4622 }
4623 }
4624 4608 }
4625 else //scale only
4626 {
4627
1/2
✓ Branch 0 taken 906 times.
✗ Branch 1 not taken.
906 if(canscale)
4628 {
4629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(opacity<128)
4630 {
4631 clear_bitmap(prim_bmp);
4632 stretch_sprite(prim_bmp, pbitty, 0, 0, xscale, yscale);
4633 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4634 }
4635 else
4636 {
4637 906 stretch_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset, xscale, yscale);
4638 }
4639 906 }
4640 else //error -do not scale
4641 {
4642 if(opacity<128)
4643 {
4644 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4645 }
4646 else
4647 {
4648 draw_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset);
4649 }
4650 }
4651 }
4652
4653 5514 script_drawing_commands.ReleaseSubBitmap(pbitty);
4654
4655 5514 }
4656 else // no scale or rotation
4657 {
4658
2/2
✓ Branch 0 taken 45760 times.
✓ Branch 1 taken 8154 times.
53914 if(transparency)
4659 {
4660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45760 times.
45760 if(opacity<=127)
4661 TileHelper::OverTileTranslucent(refbmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip, opacity);
4662 else
4663 45760 TileHelper::OverTile(refbmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip);
4664 45760 }
4665 else
4666 {
4667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8154 times.
8154 if(opacity<=127)
4668 TileHelper::PutTileTranslucent(refbmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip, opacity);
4669 else
4670 8154 TileHelper::OldPutTile(refbmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip);
4671 }
4672 }
4673 59428 }
4674
4675 void bmp_do_drawtilecloakedr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4676 {
4677 //sdci[1]=layer
4678 //sdci[2]=x
4679 //sdci[3]=y
4680 //sdci[4]=tile
4681 //sdci[5]=tile width
4682 //sdci[6]=tile height
4683 //sdci[7]=flip
4684 //sdci[17] Bitmap Pointer
4685
4686 int32_t w = sdci[5]/10000;
4687 int32_t h = sdci[6]/10000;
4688
4689 if(w < 1 || h < 1 || h > 20 || w > 20)
4690 {
4691 return;
4692 }
4693
4694 if ( sdci[17] <= 0 )
4695 {
4696 Z_scripterrlog("bitmap->DrawTileCloaked() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
4697 return;
4698 }
4699
4700 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
4701 if ( refbmp == NULL ) return;
4702
4703 int32_t flip=(sdci[7]/10000)&3;
4704
4705 int32_t x1=sdci[2]/10000;
4706 int32_t y1=sdci[3]/10000;
4707
4708 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
4709
4710 TileHelper::OverTileCloaked(refbmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, flip);
4711 }
4712
4713
4714 824 void bmp_do_drawcombor(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4715 {
4716 //sdci[1]=layer
4717 //sdci[2]=x
4718 //sdci[3]=y
4719 //sdci[4]=combo
4720 //sdci[5]=tile width
4721 //sdci[6]=tile height
4722 //sdci[7]=color (cset)
4723 //sdci[8]=scale x
4724 //sdci[9]=scale y
4725 //sdci[10]=rotation anchor x
4726 //sdci[11]=rotation anchor y
4727 //sdci[12]=rotation angle
4728 //sdci[13]=frame
4729 //sdci[14]=flip
4730 //sdci[15]=transparency
4731 //sdci[16]=opacity
4732 //sdci[17] Bitmap Pointer
4733 824 int32_t w = sdci[5]/10000;
4734 824 int32_t h = sdci[6]/10000;
4735
4736
4/8
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 824 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 824 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 824 times.
824 if(w<1||h<1||h>20||w>20)
4737 {
4738 return;
4739 }
4740
4741
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 824 times.
824 if ( sdci[17] <= 0 )
4742 {
4743 Z_scripterrlog("bitmap->DrawCombo() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
4744 return;
4745 }
4746
4747 824 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
4748
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if ( refbmp == NULL ) return;
4749 824 int32_t cmb = (sdci[4]/10000);
4750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 824 times.
824 if((unsigned)cmb >= MAXCOMBOS)
4751 {
4752 Z_scripterrlog("DrawCombo() cannot draw combo '%d', as it is out of bounds.\n", cmb);
4753 return;
4754 }
4755
4756 824 int32_t xscale=sdci[8]/10000;
4757 824 int32_t yscale=sdci[9]/10000;
4758 824 int32_t rx = sdci[10]/10000; //these work now
4759 824 int32_t ry = sdci[11]/10000; //these work now
4760 824 float rotation=sdci[12]/10000;
4761
4762 824 bool transparency=sdci[15]!=0;
4763 824 int32_t opacity=sdci[16]/10000;
4764 824 int32_t color=sdci[7]/10000;
4765 824 int32_t x1=sdci[2]/10000;
4766 824 int32_t y1=sdci[3]/10000;
4767
4768 824 const newcombo & c = combobuf[cmb];
4769 824 int32_t tiletodraw = combo_tile(c, x1, y1);
4770 824 int32_t flip = ((sdci[14]/10000) & 3) ^ c.flip;
4771 824 int32_t skiprows=c.skipanimy;
4772
4773
4774 //don't scale if it's not safe to do so
4775 824 bool canscale = true;
4776
4777
2/4
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 824 times.
824 if(xscale==0||yscale==0)
4778 {
4779 return;
4780 }
4781
4782
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 824 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
824 if(xscale<0||yscale<0)
4783 824 canscale = false; //default size
4784
4785
2/4
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 824 times.
824 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
4786
4787
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 824 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 824 times.
824 if((xscale>0 && yscale>0) || rotation) //scaled or rotated
4788 {
4789 BITMAP* pbitty = script_drawing_commands.AquireSubBitmap(w*16, h*16); //-pbitty in the hisouse. :D
4790
4791 if(transparency)
4792 {
4793 TileHelper::OverTile(pbitty, tiletodraw, 0, 0, w, h, color, flip, skiprows);
4794 }
4795 else //no transparency
4796 {
4797 TileHelper::OldPutTile(pbitty, tiletodraw, 0, 0, w, h, color, flip, skiprows);
4798 }
4799
4800 if(rotation != 0) // rotate
4801 {
4802 //fixed point sucks ;0
4803 if(rx>-777||ry>-777) //set the rotation anchor and rotate around that
4804 {
4805 int32_t xy[2];
4806 fixed ra1=itofix(sdci[12]%10000)/10000;
4807 fixed ra2=itofix(sdci[12]/10000);
4808 fixed ra=ra1+ra2;
4809 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
4810 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
4811 x1=xy[0];
4812 y1=xy[1];
4813 }
4814
4815 if(canscale) //scale first
4816 {
4817 BITMAP* tempbit = create_bitmap_ex(8, xscale>512?512:xscale, yscale>512?512:yscale);
4818 clear_bitmap(tempbit);
4819
4820 stretch_sprite(tempbit, pbitty, 0, 0, xscale, yscale);
4821
4822 if(opacity < 128)
4823 {
4824 clear_bitmap(prim_bmp);
4825 rotate_sprite(prim_bmp, tempbit, 0, 0, degrees_to_fixed(rotation));
4826 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4827 }
4828 else
4829 {
4830 rotate_sprite(refbmp, tempbit, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
4831 }
4832
4833 destroy_bitmap(tempbit);
4834 }
4835 else //no scale
4836 {
4837 if(opacity < 128)
4838 {
4839 clear_bitmap(prim_bmp);
4840 rotate_sprite(prim_bmp, pbitty, 0, 0, degrees_to_fixed(rotation));
4841 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4842 }
4843 else
4844 {
4845 rotate_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
4846 }
4847 }
4848 }
4849 else //scale only
4850 {
4851 if(canscale)
4852 {
4853 if(opacity<128)
4854 {
4855 clear_bitmap(prim_bmp);
4856 stretch_sprite(prim_bmp, pbitty, 0, 0, xscale, yscale);
4857 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4858 }
4859 else
4860 {
4861 stretch_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset, xscale, yscale);
4862 }
4863 }
4864 else //error -do not scale
4865 {
4866 if(opacity<128)
4867 {
4868 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4869 }
4870 else
4871 {
4872 draw_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset);
4873 }
4874 }
4875 }
4876
4877 script_drawing_commands.ReleaseSubBitmap(pbitty); //rap sucks
4878 }
4879 else // no scale or rotation
4880 {
4881
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if(transparency)
4882 {
4883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 824 times.
824 if(opacity<=127)
4884 TileHelper::OverTileTranslucent(refbmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, opacity, skiprows);
4885 else
4886 824 TileHelper::OverTile(refbmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, skiprows);
4887 824 }
4888 else
4889 {
4890 if(opacity<=127)
4891 TileHelper::PutTileTranslucent(refbmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, opacity, skiprows);
4892 else
4893 TileHelper::OldPutTile(refbmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, skiprows);
4894 }
4895 }
4896 824 }
4897
4898
4899 void bmp_do_drawcombocloakedr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4900 {
4901 //sdci[1]=layer
4902 //sdci[2]=x
4903 //sdci[3]=y
4904 //sdci[4]=combo
4905 //sdci[5]=tile width
4906 //sdci[6]=tile height
4907 //sdci[7]=flip
4908 //sdci[17] Bitmap Pointer
4909
4910 int32_t w = sdci[5]/10000;
4911 int32_t h = sdci[6]/10000;
4912
4913 if(w<1||h<1||h>20||w>20)
4914 {
4915 return;
4916 }
4917
4918 if ( sdci[17] <= 0 )
4919 {
4920 Z_scripterrlog("bitmap->DrawComboCloaked() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
4921 return;
4922 }
4923
4924 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
4925 if ( refbmp == NULL ) return;
4926 int32_t cmb = (sdci[4]/10000);
4927 if((unsigned)cmb >= MAXCOMBOS)
4928 {
4929 Z_scripterrlog("DrawComboCloaked() cannot draw combo '%d', as it is out of bounds.\n", cmb);
4930 return;
4931 }
4932
4933 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
4934
4935 int32_t x1=sdci[2]/10000;
4936 int32_t y1=sdci[3]/10000;
4937
4938 const newcombo & c = combobuf[cmb];
4939 int32_t tiletodraw = combo_tile(c, x1, y1);
4940 int32_t flip = ((sdci[7]/10000) & 3) ^ c.flip;
4941 int32_t skiprows=c.skipanimy;
4942
4943 TileHelper::OverTileCloaked(refbmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, flip, skiprows);
4944 }
4945
4946
4947 167316 void bmp_do_fasttiler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4948 {
4949 /* layer, x, y, tile, color opacity */
4950 //sdci[17] Bitmap Pointer
4951
4952 167316 int32_t opacity = sdci[6]/10000;
4953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 167316 times.
167316 if ( sdci[17] <= 0 )
4954 {
4955 Z_scripterrlog("bitmap->FastTile() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
4956 return;
4957 }
4958 167316 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
4959
1/2
✓ Branch 0 taken 167316 times.
✗ Branch 1 not taken.
167316 if ( refbmp == NULL ) return;
4960
4961
2/4
✓ Branch 0 taken 167316 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 167316 times.
✗ Branch 3 not taken.
167316 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
4962
4963
2/2
✓ Branch 0 taken 11131 times.
✓ Branch 1 taken 156185 times.
167316 if(opacity < 128)
4964 11131 overtiletranslucent16(refbmp, sdci[4]/10000, xoffset+(sdci[2]/10000), yoffset+(sdci[3]/10000), sdci[5]/10000, 0, opacity);
4965 else
4966 156185 overtile16(refbmp, sdci[4]/10000, xoffset+(sdci[2]/10000), yoffset+(sdci[3]/10000), sdci[5]/10000, 0);
4967 167316 }
4968
4969 void do_bmpwritetile(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4970 {
4971 /* layer, x, y, tile, is8bit, mask */
4972 //sdci[17] Bitmap Pointer
4973 if ( sdci[17] <= 0 )
4974 {
4975 Z_scripterrlog("bitmap->WriteTile() wanted to read from an invalid bitmap id: %d. Aborting.\n", sdci[17]);
4976 return;
4977 }
4978 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
4979 if ( refbmp == NULL ) return;
4980
4981 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
4982
4983 int32_t x = (sdci[2]/10000), y = (sdci[3]/10000), tl = (sdci[4]/10000);
4984 bool is8bit = sdci[5]!=0, mask = sdci[6]!=0;
4985
4986 write_tile(newtilebuf, refbmp, tl, x+xoffset, y+yoffset, is8bit, mask);
4987 }
4988
4989 void do_bmpdither(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4990 {
4991 /* layer, mask, color, ditherType, ditherArg */
4992 //sdci[2] Mask Bitmap Pointer
4993 //sdci[3] Color
4994 //sdci[17] Bitmap Pointer
4995 if ( sdci[17] <= 0 )
4996 {
4997 Z_scripterrlog("bitmap->Dither() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
4998 return;
4999 }
5000 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
5001 if ( refbmp == NULL ) return;
5002 if ( sdci[2] <= 0 )
5003 {
5004 Z_scripterrlog("bitmap->Dither() wanted to read from an invalid bitmap id: %d. Aborting.\n", sdci[2]);
5005 return;
5006 }
5007 BITMAP *mask = FFCore.GetScriptBitmap(sdci[2]-10);
5008 if ( mask == NULL ) return;
5009
5010 int32_t dType = sdci[4] / 10000L;
5011 if(dType < 0 || dType >= dithMax)
5012 {
5013 Z_scripterrlog("bitmap->Dither() used an invalid dither type: %d. Aborting.\n", dType);
5014 return;
5015 }
5016
5017 ditherblit(refbmp, mask, byte(sdci[3]/10000L), dType, sdci[5]/10000L);
5018 }
5019
5020 6363 void do_bmpreplcol(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5021 {
5022 /* layer, shift, startcol, endcol */
5023 //sdci[2] NewCol
5024 //sdci[3] StartCol
5025 //sdci[4] EndCol
5026 //sdci[17] Bitmap Pointer
5027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6363 times.
6363 if ( sdci[17] <= 0 )
5028 {
5029 Z_scripterrlog("bitmap->ReplaceColors() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
5030 return;
5031 }
5032 6363 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
5033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6363 times.
6363 if ( refbmp == NULL ) return;
5034 6363 replColor(refbmp, sdci[2]/10000L, sdci[3]/10000L, sdci[4]/10000L, false);
5035 6363 }
5036
5037 void do_bmpshiftcol(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5038 {
5039 /* layer, shift, startcol, endcol */
5040 //sdci[2] ShiftAmount
5041 //sdci[3] StartCol
5042 //sdci[4] EndCol
5043 //sdci[17] Bitmap Pointer
5044 if ( sdci[17] <= 0 )
5045 {
5046 Z_scripterrlog("bitmap->ShiftColors() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
5047 return;
5048 }
5049 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
5050 if ( refbmp == NULL ) return;
5051 replColor(refbmp, sdci[2]/10000L, sdci[3]/10000L, sdci[4]/10000L, true);
5052 }
5053
5054 906 void do_bmpmaskdraw(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5055 {
5056 /* layer, mask, color */
5057 //sdci[2] Mask Bitmap Pointer
5058 //sdci[3] Color
5059 //sdci[4] start mask color
5060 //sdci[5] end mask color
5061 //sdci[17] Bitmap Pointer
5062 906 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
5063
1/2
✓ Branch 0 taken 906 times.
✗ Branch 1 not taken.
906 if ( refbmp == NULL )
5064 {
5065 Z_scripterrlog("bitmap->MaskDraw() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
5066 return;
5067 }
5068 906 BITMAP *mask = FFCore.GetScriptBitmap(sdci[2]-10);
5069
1/2
✓ Branch 0 taken 906 times.
✗ Branch 1 not taken.
906 if ( mask == NULL )
5070 {
5071 Z_scripterrlog("bitmap->MaskDraw() wanted to read from an invalid bitmap id: %d. Aborting.\n", sdci[2]);
5072 return;
5073 }
5074 906 auto fillcol = sdci[3]/10000L;
5075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(unsigned(fillcol) > 0xFF) return; //invalid color, nothing to draw
5076 906 auto startcol = vbound(sdci[4]/10000L,0x00,0xFF);
5077 906 auto endcol = vbound(sdci[5]/10000L,0x00,0xFF);
5078 906 mask_colorfill(refbmp, mask, fillcol, startcol, endcol);
5079 906 }
5080
5081 void do_bmpmaskblit(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5082 {
5083 /* layer, mask, color */
5084 //sdci[2] Mask Bitmap Pointer
5085 //sdci[3] Pattern Bitmap
5086 //sdci[4] bool 'pattern repeats'
5087 //sdci[5] start mask color
5088 //sdci[6] end mask color
5089 //sdci[17] Bitmap Pointer
5090 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
5091 if ( refbmp == NULL )
5092 {
5093 Z_scripterrlog("bitmap->MaskDraw() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
5094 return;
5095 }
5096 BITMAP *mask = FFCore.GetScriptBitmap(sdci[2]-10);
5097 if ( mask == NULL )
5098 {
5099 Z_scripterrlog("bitmap->MaskDraw() wanted to read from an invalid bitmap (mask) id: %d. Aborting.\n", sdci[2]);
5100 return;
5101 }
5102 BITMAP *pattern = FFCore.GetScriptBitmap(sdci[3]-10);
5103 if ( pattern == NULL )
5104 {
5105 Z_scripterrlog("bitmap->MaskDraw() wanted to read from an invalid bitmap (pattern) id: %d. Aborting.\n", sdci[3]);
5106 return;
5107 }
5108 bool repeats = sdci[4]!=0;
5109 auto startcol = vbound(sdci[5]/10000L,0x00,0xFF);
5110 auto endcol = vbound(sdci[6]/10000L,0x00,0xFF);
5111 mask_blit(refbmp, mask, pattern, repeats, startcol, endcol);
5112 }
5113
5114 784 void bmp_do_fastcombor(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5115 {
5116 /* layer, x, y, tile, color opacity */
5117 //sdci[17] Bitmap Pointer
5118 784 int32_t opacity = sdci[6] / 10000;
5119 784 int32_t x1 = sdci[2] / 10000;
5120 784 int32_t y1 = sdci[3] / 10000;
5121 784 int32_t index = sdci[4]/10000;
5122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 784 times.
784 if ( sdci[17] <= 0 )
5123 {
5124 Z_scripterrlog("bitmap->FastCombo() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
5125 return;
5126 }
5127 784 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
5128
1/2
✓ Branch 0 taken 784 times.
✗ Branch 1 not taken.
784 if ( refbmp == NULL ) return;
5129 784 int32_t cmb = (sdci[4]/10000);
5130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 784 times.
784 if((unsigned)cmb >= MAXCOMBOS)
5131 {
5132 Z_scripterrlog("FastCombo() cannot draw combo '%d', as it is out of bounds.\n", cmb);
5133 return;
5134 }
5135
5136
2/4
✓ Branch 0 taken 784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 784 times.
✗ Branch 3 not taken.
784 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
5137
5138 //if( index >= MAXCOMBOS ) return; //bleh.
5139 /*
5140 const newcombo & c = combobuf[index];
5141
5142 if(opacity < 128)
5143 overtiletranslucent16(refbmp, combo_tile(c, x1, y1), xoffset+x1, yoffset+y1, sdci[5]/10000, (int32_t)c.flip, opacity);
5144 else
5145 overtile16(refbmp, combo_tile(c, x1, y1), xoffset+x1, yoffset+y1, sdci[5]/10000, (int32_t)c.flip);
5146 */
5147
5148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 784 times.
784 if(opacity < 128)
5149 {
5150 //void overcomboblocktranslucent(BITMAP *dest, int32_t x, int32_t y, int32_t cmbdat, int32_t cset, int32_t w, int32_t h, int32_t opacity)
5151 overcomboblocktranslucent(refbmp, xoffset+x1, yoffset+y1, cmb, sdci[5]/10000, 1, 1, 128);
5152
5153 }
5154 else
5155 {
5156 //overcomboblock(BITMAP *dest, int32_t x, int32_t y, int32_t cmbdat, int32_t cset, int32_t w, int32_t h)
5157 784 overcomboblock(refbmp, xoffset+x1, yoffset+y1, cmb, sdci[5]/10000, 1, 1);
5158 }
5159 784 }
5160
5161
5162
5163 void bmp_do_drawcharr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5164 {
5165 //sdci[17] Bitmap Pointer
5166 if ( sdci[17] <= 0 )
5167 {
5168 Z_scripterrlog("bitmap->DrawCharacter() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
5169 return;
5170 }
5171 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
5172 if ( refbmp == NULL ) return;
5173
5174 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
5175
5176 //broken 2.50.2 and earlier drawcharacter()
5177 if ( get_bit(quest_rules, qr_BROKENCHARINTDRAWING) )
5178 {
5179 //sdci[1]=layer
5180 //sdci[2]=x
5181 //sdci[3]=y
5182 //sdci[4]=font
5183 //sdci[5]=color
5184 //sdci[6]=bg color
5185 //sdci[7]=strech x (width)
5186 //sdci[8]=stretch y (height)
5187 //sdci[9]=char
5188 //sdci[10]=opacity
5189 //sdci[17] Bitmap Pointer
5190
5191 int32_t x=sdci[2]/10000;
5192 int32_t y=sdci[3]/10000;
5193 int32_t font_index=sdci[4]/10000;
5194 int32_t color=sdci[5]/10000;
5195 int32_t bg_color=sdci[6]/10000; //-1 = transparent
5196 int32_t w=sdci[7]/10000;
5197 int32_t h=sdci[8]/10000;
5198 char glyph=char(sdci[9]/10000);
5199 int32_t opacity=sdci[10]/10000;
5200
5201 //safe check
5202 if(bg_color < -1) bg_color = -1;
5203
5204 if(w>512) w=512; //w=vbound(w,0,512);
5205
5206 if(h>512) h=512; //h=vbound(h,0,512);
5207
5208 //undone
5209 if(w>0&&h>0)//stretch the character
5210 {
5211 BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1);
5212
5213 if(opacity < 128)
5214 {
5215 if(w>128||h>128)
5216 {
5217 clear_bitmap(prim_bmp);
5218
5219 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5220 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
5221 draw_trans_sprite(refbmp, prim_bmp, x+xoffset, y+yoffset);
5222 }
5223 else //this is faster
5224 {
5225 BITMAP *pbmp2 = script_drawing_commands.AquireSubBitmap(w,h);
5226
5227 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5228 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
5229 draw_trans_sprite(refbmp, pbmp2, x+xoffset, y+yoffset);
5230
5231 script_drawing_commands.ReleaseSubBitmap(pbmp2);
5232 }
5233 }
5234 else // no opacity
5235 {
5236 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5237 stretch_sprite(refbmp, pbmp, x+xoffset, y+yoffset, w, h);
5238 }
5239
5240 }
5241 else //no stretch
5242 {
5243 if(opacity < 128)
5244 {
5245 BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16);
5246 clear_bitmap(pbmp);
5247
5248 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5249 draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset);
5250
5251 destroy_bitmap(pbmp);
5252 }
5253 else // no opacity
5254 {
5255 textprintf_ex(refbmp, get_zc_font(font_index), x+xoffset, y+yoffset, color, bg_color, "%c", glyph);
5256 }
5257 }
5258 }
5259
5260 else //2.53.0 fixed version and later.
5261 {
5262
5263 //sdci[1]=layer
5264 //sdci[2]=x
5265 //sdci[3]=y
5266 //sdci[4]=font
5267 //sdci[5]=color
5268 //sdci[6]=bg color
5269 //sdci[7]=strech x (width)
5270 //sdci[8]=stretch y (height)
5271 //sdci[9]=char
5272 //sdci[10]=opacity
5273
5274 int32_t x=sdci[2]/10000;
5275 int32_t y=sdci[3]/10000;
5276 int32_t font_index=sdci[4]/10000;
5277 int32_t color=sdci[5]/10000;
5278 int32_t bg_color=sdci[6]/10000; //-1 = transparent
5279 int32_t w=sdci[7]/10000;
5280 int32_t h=sdci[8]/10000;
5281 char glyph=char(sdci[9]/10000);
5282 int32_t opacity=sdci[10]/10000;
5283
5284 //safe check
5285 if(bg_color < -1) bg_color = -1;
5286
5287 if(w>512) w=512; //w=vbound(w,0,512);
5288
5289 if(h>512) h=512; //h=vbound(h,0,512);
5290
5291 //undone
5292 if(w>0&&h>0)//stretch the character
5293 {
5294 BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1);
5295
5296 if(opacity < 128)
5297 {
5298 if(w>128||h>128)
5299 {
5300 clear_bitmap(prim_bmp);
5301
5302 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5303 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
5304 draw_trans_sprite(refbmp, prim_bmp, x+xoffset, y+yoffset);
5305 }
5306 else //this is faster
5307 {
5308 BITMAP *pbmp2 = script_drawing_commands.AquireSubBitmap(w,h);
5309
5310 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5311 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
5312 draw_trans_sprite(refbmp, pbmp2, x+xoffset, y+yoffset);
5313
5314 script_drawing_commands.ReleaseSubBitmap(pbmp2);
5315 }
5316 }
5317 else // no opacity
5318 {
5319 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5320 stretch_sprite(refbmp, pbmp, x+xoffset, y+yoffset, w, h);
5321 }
5322
5323 }
5324 else //no stretch
5325 {
5326 if(opacity < 128)
5327 {
5328 BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16);
5329 clear_bitmap(pbmp);
5330
5331 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5332 draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset);
5333
5334 destroy_bitmap(pbmp);
5335 }
5336 else // no opacity
5337 {
5338 textprintf_ex(refbmp, get_zc_font(font_index), x+xoffset, y+yoffset, color, bg_color, "%c", glyph);
5339 }
5340 }
5341
5342 }
5343
5344 }
5345
5346
5347 void bmp_do_drawintr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5348 {
5349 if ( sdci[17] <= 0 )
5350 {
5351 Z_scripterrlog("bitmap->DrawInteger() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
5352 return;
5353 }
5354 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
5355 if ( refbmp == NULL ) return;
5356
5357 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
5358
5359 //broken 2.50.2 and earlier drawinteger()
5360 if ( get_bit(quest_rules, qr_BROKENCHARINTDRAWING) )
5361 {
5362 //sdci[1]=layer
5363 //sdci[2]=x
5364 //sdci[3]=y
5365 //sdci[4]=font
5366 //sdci[5]=color
5367 //sdci[6]=bg color
5368 //sdci[7]=strech x (width)
5369 //sdci[8]=stretch y (height)
5370 //sdci[9]=integer
5371 //sdci[10]=num decimal places
5372 //sdci[11]=opacity
5373 //sdci[17] Bitmap Pointer
5374
5375 int32_t x=sdci[2]/10000;
5376 int32_t y=sdci[3]/10000;
5377 int32_t font_index=sdci[4]/10000;
5378 int32_t color=sdci[5]/10000;
5379 int32_t bg_color=sdci[6]/10000; //-1 = transparent
5380 int32_t w=sdci[7]/10000;
5381 int32_t h=sdci[8]/10000;
5382 //float number=static_cast<float>(sdci[9])/10000.0f;
5383 int32_t decplace=sdci[10]/10000;
5384 int32_t opacity=sdci[11]/10000;
5385
5386 //safe check
5387 if(bg_color < -1) bg_color = -1;
5388
5389 if(w>512) w=512; //w=vbound(w,0,512);
5390
5391 if(h>512) h=512; //h=vbound(h,0,512);
5392
5393 char numbuf[15];
5394
5395 switch(decplace)
5396 {
5397 default:
5398 case 0:
5399 sprintf(numbuf,"%d",(sdci[9]/10000)); //For some reason, static casting for zero decimal places was
5400 break; //reducing the value by -1, so 8.000 printed as '7'. -Z
5401
5402 case 1:
5403 //sprintf(numbuf,"%.01f",number);
5404 sprintf(numbuf,"%.01f",(static_cast<float>(sdci[9])/10000.0f)); //Would this be slower?
5405 break;
5406
5407 case 2:
5408 //sprintf(numbuf,"%.02f",number);
5409 sprintf(numbuf,"%.02f",(static_cast<float>(sdci[9])/10000.0f));
5410 break;
5411
5412 case 3:
5413 //sprintf(numbuf,"%.03f",number);
5414 sprintf(numbuf,"%.03f",(static_cast<float>(sdci[9])/10000.0f));
5415 break;
5416
5417 case 4:
5418 //sprintf(numbuf,"%.04f",number);
5419 sprintf(numbuf,"%.04f",(static_cast<float>(sdci[9])/10000.0f));
5420 break;
5421 }
5422
5423 if(w>0&&h>0)//stretch
5424 {
5425 BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1);
5426
5427 if(opacity < 128)
5428 {
5429 if(w>128||h>128)
5430 {
5431 clear_bitmap(prim_bmp);
5432
5433 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5434 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
5435 draw_trans_sprite(refbmp, prim_bmp, x+xoffset, y+yoffset);
5436 }
5437 else
5438 {
5439 BITMAP *pbmp2 = create_sub_bitmap(prim_bmp,0,0,w,h);
5440 clear_bitmap(pbmp2);
5441
5442 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5443 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
5444 draw_trans_sprite(refbmp, pbmp2, x+xoffset, y+yoffset);
5445
5446 destroy_bitmap(pbmp2);
5447 }
5448 }
5449 else // no opacity
5450 {
5451 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5452 stretch_sprite(refbmp, pbmp, x+xoffset, y+yoffset, w, h);
5453 }
5454
5455 }
5456 else //no stretch
5457 {
5458 if(opacity < 128)
5459 {
5460 BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16);
5461 clear_bitmap(pbmp);
5462
5463 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5464 draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset);
5465
5466 destroy_bitmap(pbmp);
5467 }
5468 else // no opacity
5469 {
5470 textout_ex(refbmp, get_zc_font(font_index), numbuf, x+xoffset, y+yoffset, color, bg_color);
5471 }
5472 }
5473
5474 }
5475
5476 else //2.53.0 fixed version and later.
5477 {
5478 //sdci[1]=layer
5479 //sdci[2]=x
5480 //sdci[3]=y
5481 //sdci[4]=font
5482 //sdci[5]=color
5483 //sdci[6]=bg color
5484 //sdci[7]=strech x (width)
5485 //sdci[8]=stretch y (height)
5486 //sdci[9]=integer
5487 //sdci[10]=num decimal places
5488 //sdci[11]=opacity
5489
5490 int32_t x=sdci[2]/10000;
5491 int32_t y=sdci[3]/10000;
5492 int32_t font_index=sdci[4]/10000;
5493 int32_t color=sdci[5]/10000;
5494 int32_t bg_color=sdci[6]/10000; //-1 = transparent
5495 int32_t w=sdci[7]/10000;
5496 int32_t h=sdci[8]/10000;
5497 //float number=static_cast<float>(sdci[9])/10000.0f;
5498 //int32_t numberint = sdci[9]/10000;
5499 int32_t decplace=sdci[10]/10000;
5500 int32_t opacity=sdci[11]/10000;
5501
5502 //safe check
5503 if(bg_color < -1) bg_color = -1;
5504
5505 if(w>512) w=512; //w=vbound(w,0,512);
5506
5507 if(h>512) h=512; //h=vbound(h,0,512);
5508
5509 char numbuf[15];
5510
5511 switch(decplace)
5512 {
5513 default:
5514 case 0:
5515 sprintf(numbuf,"%d",(sdci[9]/10000)); //For some reason, static casting for zero decimal places was
5516 break; //reducing the value by -1, so 8.000 printed as '7'. -Z
5517
5518 case 1:
5519 //sprintf(numbuf,"%.01f",number);
5520 sprintf(numbuf,"%.01f",(static_cast<float>(sdci[9])/10000.0f)); //Would this be slower?
5521 break;
5522
5523 case 2:
5524 //sprintf(numbuf,"%.02f",number);
5525 sprintf(numbuf,"%.02f",(static_cast<float>(sdci[9])/10000.0f));
5526 break;
5527
5528 case 3:
5529 //sprintf(numbuf,"%.03f",number);
5530 sprintf(numbuf,"%.03f",(static_cast<float>(sdci[9])/10000.0f));
5531 break;
5532
5533 case 4:
5534 //sprintf(numbuf,"%.04f",number);
5535 sprintf(numbuf,"%.04f",(static_cast<float>(sdci[9])/10000.0f));
5536 break;
5537 }
5538
5539 //FONT* font=get_zc_font(sdci[4]/10000);
5540
5541 if(w>0&&h>0)//stretch
5542 {
5543 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, text_length(get_zc_font(font_index), numbuf)+1, text_height(get_zc_font(font_index)));
5544 clear_bitmap(pbmp);
5545 //script_drawing_commands.GetSmallTextureBitmap(1,1);
5546
5547 if(opacity < 128)
5548 {
5549 if(w>128||h>128)
5550 {
5551 clear_bitmap(prim_bmp);
5552
5553 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5554 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
5555 draw_trans_sprite(refbmp, prim_bmp, x+xoffset, y+yoffset);
5556 }
5557 else
5558 {
5559 BITMAP *pbmp2 = create_sub_bitmap(prim_bmp,0,0,w,h);
5560 clear_bitmap(pbmp2);
5561
5562 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5563 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
5564 draw_trans_sprite(refbmp, pbmp2, x+xoffset, y+yoffset);
5565
5566 destroy_bitmap(pbmp2);
5567 }
5568 }
5569 else // no opacity
5570 {
5571 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5572 stretch_sprite(refbmp, pbmp, x+xoffset, y+yoffset, w, h);
5573 }
5574
5575 }
5576 else //no stretch
5577 {
5578 if(opacity < 128)
5579 {
5580 FONT* font = get_zc_font(font_index);
5581 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, text_length(font, numbuf), text_height(font));
5582 clear_bitmap(pbmp);
5583
5584 textout_ex(pbmp, font, numbuf, 0, 0, color, bg_color);
5585 draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset);
5586
5587 destroy_bitmap(pbmp);
5588 }
5589 else // no opacity
5590 {
5591 textout_ex(refbmp, get_zc_font(font_index), numbuf, x+xoffset, y+yoffset, color, bg_color);
5592 }
5593 }
5594 }
5595 }
5596
5597
5598 void bmp_do_drawstringr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5599 {
5600 //sdci[1]=layer
5601 //sdci[2]=x
5602 //sdci[3]=y
5603 //sdci[4]=font
5604 //sdci[5]=color
5605 //sdci[6]=bg color
5606 //sdci[7]=format_option
5607 //sdci[8]=string
5608 //sdci[9]=opacity
5609 //sdci[17] Bitmap Pointer
5610 if ( sdci[17] <= 0 )
5611 {
5612 Z_scripterrlog("bitmap->DrawString() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
5613 return;
5614 }
5615
5616 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
5617 if ( refbmp == NULL ) return;
5618
5619 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
5620
5621 std::string* str = (std::string*)script_drawing_commands[i].GetPtr();
5622
5623 if(!str)
5624 {
5625 al_trace("String pointer is null! Internal error. \n");
5626 return;
5627 }
5628
5629 int32_t x=sdci[2]/10000;
5630 int32_t y=sdci[3]/10000;
5631 FONT* font=get_zc_font(sdci[4]/10000);
5632 int32_t color=sdci[5]/10000;
5633 int32_t bg_color=sdci[6]/10000; //-1 = transparent
5634 int32_t format_type=sdci[7]/10000;
5635 int32_t opacity=sdci[9]/10000;
5636 //sdci[8] not needed :)
5637
5638 //safe check
5639 if(bg_color < -1) bg_color = -1;
5640
5641 if(opacity < 128)
5642 {
5643 int32_t width=zc_min(text_length(font, str->c_str()), 512);
5644 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, width, text_height(font));
5645 clear_bitmap(pbmp);
5646 textout_ex(pbmp, font, str->c_str(), 0, 0, color, bg_color);
5647 if(format_type == 2) // right-sided text
5648 x-=width;
5649 else if(format_type == 1) // centered text
5650 x-=width/2;
5651 draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset);
5652 destroy_bitmap(pbmp);
5653 }
5654 else // no opacity
5655 {
5656 if(format_type == 2) // right-sided text
5657 {
5658 textout_right_ex(refbmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color);
5659 }
5660 else if(format_type == 1) // centered text
5661 {
5662 textout_centre_ex(refbmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color);
5663 }
5664 else // standard left-sided text
5665 {
5666 textout_ex(refbmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color);
5667 }
5668 }
5669 }
5670
5671 45504 void bmp_do_drawstringr2(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5672 {
5673 //sdci[1]=layer
5674 //sdci[2]=x
5675 //sdci[3]=y
5676 //sdci[4]=font
5677 //sdci[5]=color
5678 //sdci[6]=bg color
5679 //sdci[7]=format_option
5680 //sdci[8]=string
5681 //sdci[9]=opacity
5682 //sdci[10]=shadowtype
5683 //sdci[11]=shadow_color
5684 //sdci[17] Bitmap Pointer
5685
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45504 times.
45504 if ( sdci[17] <= 0 )
5686 {
5687 Z_scripterrlog("bitmap->DrawString() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
5688 return;
5689 }
5690
5691 45504 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
5692
1/2
✓ Branch 0 taken 45504 times.
✗ Branch 1 not taken.
45504 if ( refbmp == NULL ) return;
5693
5694
2/4
✓ Branch 0 taken 45504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 45504 times.
45504 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
5695
5696 45504 std::string* str = (std::string*)script_drawing_commands[i].GetPtr();
5697
5698
1/2
✓ Branch 0 taken 45504 times.
✗ Branch 1 not taken.
45504 if(!str)
5699 {
5700 al_trace("String pointer is null! Internal error. \n");
5701 return;
5702 }
5703
5704 45504 int32_t x=sdci[2]/10000;
5705 45504 int32_t y=sdci[3]/10000;
5706 45504 FONT* font=get_zc_font(sdci[4]/10000);
5707 45504 int32_t color=sdci[5]/10000;
5708 45504 int32_t bg_color=sdci[6]/10000; //-1 = transparent
5709 45504 int32_t format_type=sdci[7]/10000;
5710 45504 int32_t opacity=sdci[9]/10000;
5711 45504 int32_t textstyle = sdci[10]/10000;
5712 45504 int32_t shadow_color = sdci[11]/10000;
5713 //sdci[8] not needed :)
5714
5715 //safe check
5716
1/2
✓ Branch 0 taken 45504 times.
✗ Branch 1 not taken.
45504 if(bg_color < -1) bg_color = -1;
5717
5718
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45504 times.
45504 if(opacity < 128)
5719 {
5720 int32_t width=zc_min(text_length(font, str->c_str()), 512);
5721 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, width, text_height(font));
5722 clear_bitmap(pbmp);
5723 textout_styled_aligned_ex(pbmp, font, str->c_str(), 0, 0, textstyle, sstaLEFT, color, shadow_color, bg_color);
5724 if(format_type == 2) // right-sided text
5725 x-=width;
5726 else if(format_type == 1) // centered text
5727 x-=width/2;
5728 draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset);
5729 destroy_bitmap(pbmp);
5730 }
5731 else // no opacity
5732 {
5733 45504 textout_styled_aligned_ex(refbmp, font, str->c_str(), x+xoffset, y+yoffset, textstyle, format_type, color, shadow_color, bg_color);
5734 }
5735 45504 }
5736
5737 26369 void bmp_do_clearr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5738 {
5739 //sdci[1]=layer
5740 //sdci[17] Bitmap Pointer
5741 //Z_scripterrlog("bitmap->Clear() pointer is: %d\n", sdci[17]);
5742
1/2
✓ Branch 0 taken 26369 times.
✗ Branch 1 not taken.
26369 if ( sdci[17] <= 0 )
5743 {
5744 Z_scripterrlog("bitmap->Clear() wanted to use to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
5745 return;
5746 }
5747 26369 int32_t bitid = sdci[17] - 10;
5748
1/2
✓ Branch 0 taken 26369 times.
✗ Branch 1 not taken.
26369 if ( scb.script_created_bitmaps[bitid].u_bmp )
5749 26369 clear_bitmap(scb.script_created_bitmaps[bitid].u_bmp);
5750 26369 }
5751
5752 2790 void bmp_do_clearcolorr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5753 {
5754 //sdci[1]=layer
5755 //sdci[2]=color
5756 //sdci[17] Bitmap Pointer
5757 2790 int32_t pal_color = sdci[2]/10000;
5758
1/2
✓ Branch 0 taken 2790 times.
✗ Branch 1 not taken.
2790 if ( sdci[17] <= 0 )
5759 {
5760 Z_scripterrlog("bitmap->ClearToColor() wanted to use to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
5761 return;
5762 }
5763 2790 int32_t bitid = sdci[17] - 10;
5764
1/2
✓ Branch 0 taken 2790 times.
✗ Branch 1 not taken.
2790 if ( scb.script_created_bitmaps[bitid].u_bmp )
5765 2790 clear_to_color(scb.script_created_bitmaps[bitid].u_bmp, pal_color);
5766 2790 }
5767
5768
5769 34653 void bmp_do_regenr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5770 {
5771 //sdci[1]=layer
5772 34653 int32_t h = sdci[3]/10000;
5773 34653 int32_t w = sdci[2]/10000;
5774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34653 times.
34653 if ( get_bit(quest_rules, qr_OLDCREATEBITMAP_ARGS) )
5775 {
5776 //flip height and width
5777 h = h ^ w;
5778 w = h ^ w;
5779 h = h ^ w;
5780 }
5781 //sdci[17] Bitmap Pointer
5782 //Z_scripterrlog("bitmap->Create() pointer is: %d\n", sdci[17]);
5783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34653 times.
34653 if ( sdci[17] <= 0 )
5784 {
5785 Z_scripterrlog("bitmap->Create() wanted to use to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
5786 return;
5787 }
5788 34653 int32_t bitid = sdci[17] - 10;
5789
2/2
✓ Branch 0 taken 34528 times.
✓ Branch 1 taken 125 times.
34653 if ( scb.script_created_bitmaps[bitid].u_bmp )
5790 34528 destroy_bitmap(scb.script_created_bitmaps[bitid].u_bmp);
5791 34653 scb.script_created_bitmaps[bitid].u_bmp = create_bitmap_ex(8,w,h);
5792
5793 34653 scb.script_created_bitmaps[bitid].width = w;
5794 34653 scb.script_created_bitmaps[bitid].height = h;
5795
5796
5797
5798 34653 }
5799
5800 void bmp_do_readr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5801 {
5802 //sdci[1]=layer
5803 //sdci[2]=filename
5804 //sdci[3]=y
5805 //sdci[4]=font
5806 //sdci[5]=color
5807 //sdci[6]=bg color
5808 //sdci[7]=format_option
5809 //sdci[8]=string
5810 //sdci[9]=opacity
5811 //sdci[17] Bitmap Pointer
5812 //Z_scripterrlog("bitmap->Read() pointer is: %d\n", sdci[17]);
5813 if ( sdci[17] <= 0 )
5814 {
5815 Z_scripterrlog("bitmap->Read() wanted to use to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
5816 return;
5817 }
5818 int32_t bitid = sdci[17] - 10;
5819 scb.script_created_bitmaps[bitid].destroy();
5820
5821 std::string* str = (std::string*)script_drawing_commands[i].GetPtr();
5822
5823 //char *cptr = new char[str->size()+1]; // +1 to account for \0 byte
5824 // std::strncpy(cptr, str->c_str(), str->size());
5825 // Z_scripterrlog("The following should be the filename string:\n");
5826 //Z_scripterrlog(" %s\n", cptr);
5827
5828 if(!str)
5829 {
5830 al_trace("String pointer is null! Internal error. \n");
5831 return;
5832 }
5833
5834 // Z_scripterrlog("Trying to read filename %s\n", cptr);
5835 PALETTE tempPal;
5836 get_palette(tempPal);
5837 if ( checkPath(str->c_str(), false) )
5838 {
5839 scb.script_created_bitmaps[bitid].u_bmp = load_bitmap(str->c_str(), tempPal);
5840 scb.script_created_bitmaps[bitid].width = scb.script_created_bitmaps[bitid].u_bmp->w;
5841 scb.script_created_bitmaps[bitid].height = scb.script_created_bitmaps[bitid].u_bmp->h;
5842 if ( !scb.script_created_bitmaps[bitid].u_bmp )
5843 {
5844 Z_scripterrlog("Failed to load image file %s.\nMaking a blank bitmap on the pointer.\n", str->c_str());
5845 //scb.script_created_bitmaps[bitid].u_bmp = create_bitmap_ex(8,256,176);
5846 //clear_bitmap(scb.script_created_bitmaps[bitid].u_bmp);
5847 }
5848 else
5849 {
5850 zprint("Read image file %s\n",str->c_str());
5851 }
5852 }
5853 else
5854 {
5855 Z_scripterrlog("Failed to load image file: %s. File not found. Creating a blank bitmap on the pointer.\n", str->c_str());
5856 scb.script_created_bitmaps[bitid].u_bmp = create_bitmap_ex(8,256,176);
5857 clear_bitmap(scb.script_created_bitmaps[bitid].u_bmp);
5858 }
5859 }
5860
5861
5862
5863 void bmp_do_writer(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5864 {
5865 //sdci[1]=layer
5866 //sdci[2]=filename
5867 //sdci[3]=y
5868 //sdci[4]=font
5869 //sdci[5]=color
5870 //sdci[6]=bg color
5871 //sdci[7]=format_option
5872 //sdci[8]=string
5873 //sdci[9]=opacity
5874 //sdci[17] Bitmap Pointer
5875 //Z_scripterrlog("bitmap->Write() pointer is: %d\n", sdci[17]);
5876
5877 if ( sdci[17] <= 0 )
5878 {
5879 Z_scripterrlog("bitmap->Write() wanted to use to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
5880 return;
5881 }
5882 int32_t bitid = sdci[17] - 10;
5883
5884 if ( !scb.script_created_bitmaps[bitid].u_bmp )
5885 {
5886 Z_scripterrlog("Tried to write from an invalid bitmap pointer %d. Aborting. \n", sdci[17]);
5887 return;
5888 }
5889
5890 bool overwrite = (sdci[3] != 0);
5891 std::string* str = (std::string*)script_drawing_commands[i].GetPtr();
5892
5893 if(!str)
5894 {
5895 al_trace("String pointer is null! Internal error. \n");
5896 return;
5897 }
5898
5899 //char *cptr = new char[str->size()+1]; // +1 to account for \0 byte
5900 //std::strncpy(cptr, str->c_str(), str->size());
5901 //Z_scripterrlog("bitmap->Write extension matches ? : %s\n!", (FFCore.checkExtension(str->c_str(), ".png")) ? "true" : "false");
5902 //Z_scripterrlog("Trying to write filename %s\n", cptr);
5903 if
5904 (
5905 ( (FFCore.checkExtension(*str, "")) ) ||
5906 ( !(FFCore.checkExtension(*str, ".png")) && !(FFCore.checkExtension(*str, ".gif")) && !(FFCore.checkExtension(*str, ".bmp"))
5907 && !(FFCore.checkExtension(*str, ".pcx")) && !(FFCore.checkExtension(*str, ".tga")) )
5908 )
5909 {
5910 Z_scripterrlog("No extension, or invalid extension provided for writing bitmap file %s. Could not write the file.\nValid types are .png, .gif, .pcx, .tgx, and .bmp. Aborting.\n",str->c_str());
5911 }
5912 else if ( overwrite || (!checkPath(str->c_str(), false)) )
5913 {
5914 if(create_path(str->c_str()))
5915 {
5916 save_bitmap(str->c_str(), scb.script_created_bitmaps[bitid].u_bmp, RAMpal);
5917 if(checkPath(str->c_str(), false))
5918 {
5919 zprint("Wrote image file %s\n",str->c_str());
5920 }
5921 else
5922 {
5923 Z_scripterrlog("Failed to create file '%s'\n",str->c_str());
5924 }
5925 }
5926 else
5927 {
5928 Z_scripterrlog("Cannot write file '%s' because the directory does not exist, and could not be created.\n", str->c_str());
5929 }
5930 }
5931 else Z_scripterrlog("Cannot write file '%s' because the file already exists in the specified path.\n", str->c_str());
5932 }
5933
5934
5935 void bmp_do_drawquadr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5936 {
5937 //sdci[1]=layer
5938 //sdci[2]=x1
5939 //sdci[3]=y1
5940 //sdci[4]=x2
5941 //sdci[5]=y2
5942 //sdci[6]=x3
5943 //sdci[7]=y3
5944 //sdci[8]=x4
5945 //sdci[9]=y4
5946 //sdci[10]=width
5947 //sdci[11]=height
5948 //sdci[12]=cset
5949 //sdci[13]=flip
5950 //sdci[14]=tile/combo
5951 //sdci[15]=polytype
5952 //sdci[16] = other bitmap as texture
5953 //sdci[17] Bitmap Pointer
5954 Z_scripterrlog("bitmap quad pointer: %d\n", sdci[17]);
5955 if ( sdci[17] <= 0 )
5956 {
5957 Z_scripterrlog("bitmap->Quad() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
5958 return;
5959 }
5960 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
5961
5962 if ( !refbmp ) return;
5963
5964 int32_t x1 = sdci[2]/10000;
5965 int32_t y1 = sdci[3]/10000;
5966 int32_t x2 = sdci[4]/10000;
5967 int32_t y2 = sdci[5]/10000;
5968 int32_t x3 = sdci[6]/10000;
5969 int32_t y3 = sdci[7]/10000;
5970 int32_t x4 = sdci[8]/10000;
5971 int32_t y4 = sdci[9]/10000;
5972 int32_t w = sdci[10]/10000;
5973 int32_t h = sdci[11]/10000;
5974 int32_t color = sdci[12]/10000;
5975 int32_t flip=(sdci[13]/10000)&3;
5976 int32_t tile = sdci[14]/10000;
5977 int32_t polytype = sdci[15]/10000;
5978 int32_t quad_render_source = sdci[16]-10;
5979 //Z_scripterrlog("bitmap->Quad() render source is: %d\n", quad_render_source);
5980
5981 bool tex_is_bitmap = ( sdci[16] != 0 );
5982
5983 BITMAP *bmptexture=NULL;
5984 BITMAP *tex=NULL;
5985 polytype = vbound(polytype, 0, 14);
5986
5987 int32_t col[4];
5988 col[0]=col[1]=col[2]=col[3]=color;
5989 bool mustDestroyBmp = false;
5990
5991 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
5992
5993 if ( tex_is_bitmap )
5994 {
5995 bmptexture = FFCore.GetScriptBitmap(quad_render_source);
5996 if ( !bmptexture )
5997 {
5998 Z_scripterrlog("Bitmap pointer used as a texture in %s is uninitialised.\n Defaulting to using a tile as a texture.\n", "bitmap->Triangle3()");
5999 tex_is_bitmap = 0;
6000 }
6001 }
6002
6003 if ( tex_is_bitmap )
6004 {
6005
6006 if ( !isPowerOfTwo(bmptexture->h) ) Z_scripterrlog("HEIGHT of Bitmap ( pointer %d ) provided as a render source for bitmap->Quad is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source);
6007 if ( !isPowerOfTwo(bmptexture->w) ) Z_scripterrlog("WIDTH of Bitmap ( pointer %d ) provided as a render source for bitmap->Quad is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source);
6008 if ( !isPowerOfTwo(w) ) Z_scripterrlog("WIDTH ARG (%d) provided as a render source for bitmap->Quad is not a POWER OF TWO.\nTextels may render improperly!\n", w);
6009 if ( !isPowerOfTwo(h) ) Z_scripterrlog("HEIGHT ARG (%d) provided as a render source for bitmap->Quad is not a POWER OF TWO.\nTextels may render improperly!\n", h);
6010
6011 V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] };
6012 V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(h), col[1] };
6013 V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(w), static_cast<float>(h), col[2] };
6014 V3D_f V4 = { static_cast<float>(x4+xoffset), static_cast<float>(y4+yoffset), 0, static_cast<float>(w), 0, col[3] };
6015
6016 quad3d_f(refbmp, polytype, bmptexture, &V1, &V2, &V3, &V4);
6017 }
6018 else
6019 {
6020 tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
6021 if(!tex)
6022 {
6023 //Z_scripterrlog("Bitmap->Quad() found an invalid texture bitmap.\n");
6024 mustDestroyBmp = true;
6025 tex = create_bitmap_ex(8, w*16, h*16);
6026 clear_bitmap(tex);
6027 }
6028
6029 if(tile > 0) // TILE
6030 {
6031 TileHelper::OverTile(tex, tile, 0, 0, w, h, color, flip);
6032 }
6033
6034 if ( tile < 0 ) // COMBO
6035 {
6036 const newcombo & c = combobuf[ vbound(abs(tile), 0, 0xffff) ];
6037 const int32_t tiletodraw = combo_tile(c, x1, y1);
6038 flip = flip ^ c.flip;
6039
6040 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, color, flip);
6041 }
6042 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
6043 {
6044 Z_message("Quad() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
6045 return; //non power of two error
6046 }
6047 //Z_scripterrlog("bitmap->Quad() is trying to blit from a bitmap texture.\n");
6048 V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] };
6049 V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(h), col[1] };
6050 V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(w), static_cast<float>(h), col[2] };
6051 V3D_f V4 = { static_cast<float>(x4+xoffset), static_cast<float>(y4+yoffset), 0, static_cast<float>(w), 0, col[3] };
6052
6053 quad3d_f(refbmp, polytype, tex, &V1, &V2, &V3, &V4);
6054
6055 }
6056
6057
6058
6059
6060 //todo: finish palette shading
6061 /*
6062 POLYTYPE_FLAT
6063 POLYTYPE_GCOL
6064 POLYTYPE_GRGB
6065 POLYTYPE_ATEX
6066 POLYTYPE_PTEX
6067 POLYTYPE_ATEX_MASK
6068 POLYTYPE_PTEX_MASK
6069 POLYTYPE_ATEX_LIT
6070 POLYTYPE_PTEX_LIT
6071 POLYTYPE_ATEX_MASK_LIT
6072 POLYTYPE_PTEX_MASK_LIT
6073 POLYTYPE_ATEX_TRANS
6074 POLYTYPE_PTEX_TRANS
6075 POLYTYPE_ATEX_MASK_TRANS
6076 POLYTYPE_PTEX_MASK_TRANS
6077 */
6078
6079 if(mustDestroyBmp)
6080 destroy_bitmap(tex);
6081
6082 }
6083
6084
6085 void bmp_do_getpixelr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
6086 {
6087 //sdci[1]=layer
6088 //sdci[2]=x1
6089 //sdci[3]=y1
6090
6091 //sdci[17] Bitmap Pointer
6092 if ( sdci[17] <= 0 )
6093 {
6094 Z_scripterrlog("bitmap->GetPixel() wanted to read from an invalid bitmap id: %d. Aborting.\n", sdci[17]);
6095 return;
6096 }
6097 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
6098 if ( refbmp == NULL ) return;
6099
6100
6101 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
6102
6103 int32_t x1 = sdci[2]/10000;
6104 int32_t y1 = (sdci[3]/10000)+yoffset;
6105 int32_t col = getpixel(scb.script_created_bitmaps[(sdci[17]-10)].u_bmp, x1, y1);
6106 Z_scripterrlog("bitmap->GetPixel col is %d\n",col);
6107 Z_scripterrlog("bitmap->GetPixel bitmap ptr is is %d\n",(sdci[17]-10));
6108 FFCore.set_sarg1(col);
6109 }
6110
6111
6112
6113
6114 void bmp_do_drawtriangler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
6115 {
6116 //sdci[1]=layer
6117 //sdci[2]=x1
6118 //sdci[3]=y1
6119 //sdci[4]=x2
6120 //sdci[5]=y2
6121 //sdci[6]=x3
6122 //sdci[7]=y3
6123 //sdci[8]=width
6124 //sdci[9]=height
6125 //sdci[10]=cset
6126 //sdci[11]=flip
6127 //sdci[12]=tile/combo
6128 //sdci[13]=polytype
6129 //sdci[17] Bitmap Pointer
6130 if ( sdci[17] <= 0 )
6131 {
6132 Z_scripterrlog("bitmap->Triangle() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
6133 return;
6134 }
6135 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
6136 if ( refbmp == NULL ) return;
6137
6138
6139 int32_t render_source = sdci[14]-10;
6140 //Z_scripterrlog("bitmap->Triangle() render source is: %d\n", render_source);
6141
6142 bool tex_is_bitmap = ( sdci[14] != 0 );
6143
6144 BITMAP *bmptexture=NULL;
6145 if ( tex_is_bitmap )
6146 {
6147 bmptexture = FFCore.GetScriptBitmap(render_source);
6148 if ( !bmptexture )
6149 {
6150 Z_scripterrlog("Bitmap pointer used as a texture in %s is uninitialised.\n Defaulting to using a tile as a texture.\n", "bitmap->Triangle3()");
6151 tex_is_bitmap = 0;
6152 }
6153 }
6154
6155 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
6156
6157 int32_t x1 = sdci[2]/10000;
6158 int32_t y1 = sdci[3]/10000;
6159 int32_t x2 = sdci[4]/10000;
6160 int32_t y2 = sdci[5]/10000;
6161 int32_t x3 = sdci[6]/10000;
6162 int32_t y3 = sdci[7]/10000;
6163 int32_t w = sdci[8]/10000;
6164 int32_t h = sdci[9]/10000;
6165 int32_t color = sdci[10]/10000;
6166 int32_t flip=(sdci[11]/10000)&3;
6167 int32_t tile = sdci[12]/10000;
6168 int32_t polytype = sdci[13]/10000;
6169
6170 polytype = vbound(polytype, 0, 14);
6171 int32_t utex_w = w;
6172 int32_t utex_h = h;
6173
6174
6175 int32_t tex_width = w*16;
6176 int32_t tex_height = h*16;
6177
6178 bool mustDestroyBmp = false;
6179 BITMAP *tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
6180
6181 if(!tex)
6182 {
6183 mustDestroyBmp = true;
6184 tex = create_bitmap_ex(8, tex_width, tex_height);
6185 clear_bitmap(tex);
6186 }
6187
6188 int32_t col[3];
6189 /*
6190 if( color < 0 )
6191 {
6192 col[0]=draw_container.color_buffer[0];
6193 col[1]=draw_container.color_buffer[1];
6194 col[2]=draw_container.color_buffer[2];
6195 }
6196 else */
6197 {
6198 col[0]=col[1]=col[2]=color;
6199 }
6200
6201 if(tile > 0) // TILE
6202 {
6203 TileHelper::OverTile(tex, tile, 0, 0, w, h, color, flip);
6204 }
6205 else // COMBO
6206 {
6207 const newcombo & c = combobuf[ vbound(abs(tile), 0, 0xffff) ];
6208 const int32_t tiletodraw = combo_tile(c, x1, y1);
6209 flip = flip ^ c.flip;
6210
6211 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, color, flip);
6212 }
6213 if ( !tex_is_bitmap )
6214 {
6215 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
6216 {
6217 Z_message("bitmap->Triangle() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
6218 return; //non power of two error
6219 }
6220 V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] };
6221 V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(tex_height), col[1] };
6222 V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(tex_width), static_cast<float>(tex_height), col[2] };
6223
6224
6225 triangle3d_f(refbmp, polytype, tex, &V1, &V2, &V3);
6226
6227 }
6228
6229 else
6230 {
6231 if ( !isPowerOfTwo(bmptexture->h) ) Z_scripterrlog("HEIGHT of Bitmap ( pointer %d ) provided as a render source for bitmap->Triangle is not a POWER OF TWO.\nTextels may render improperly!\n", render_source);
6232 if ( !isPowerOfTwo(bmptexture->w) ) Z_scripterrlog("WIDTH of Bitmap ( pointer %d ) provided as a render source for bitmap->Triangle is not a POWER OF TWO.\nTextels may render improperly!\n", render_source);
6233 if ( !isPowerOfTwo(utex_h) ) Z_scripterrlog("WIDTH ARG (%d) provided as a render source for bitmap->Triangle is not a POWER OF TWO.\nTextels may render improperly!\n", utex_w);
6234 if ( !isPowerOfTwo(utex_w) ) Z_scripterrlog("HEIGHT ARG (%d) provided as a render source for bitmap->Triangle is not a POWER OF TWO.\nTextels may render improperly!\n", utex_h);
6235
6236 V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] };
6237 V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(utex_h), col[1] };
6238 V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(utex_w), static_cast<float>(utex_h), col[2] };
6239
6240
6241 triangle3d_f(refbmp, polytype, bmptexture, &V1, &V2, &V3);
6242
6243 }
6244
6245 if(mustDestroyBmp)
6246 destroy_bitmap(tex);
6247 }
6248
6249
6250 void bmp_do_mode7r(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
6251 {
6252 /*
6253 int32_t layer, int32_t rt, int32_t srcX, int32_t srcY, int32_t srcW, int32_t srcH, int32_t destW, int32_t destH, int32_t angle, int32_t cx, int32_t cy, int32_t space_z, int32_t horizon,
6254 int32_t scale_x, int32_t scale_y){
6255
6256 //sdci[1]=layer
6257 //sdci[2]=bitmap target
6258 //
6259 // -2 is the current Render Target
6260 // -1, this is the screen (framebuf).
6261 // 0: Render target 0
6262 // 1: Render target 1
6263 // 2: Render target 2
6264 // 3: Render target 3
6265 // 4: Render target 4
6266 // 5: Render target 5
6267 // 6: Render target 6
6268 // Otherwise: The pointer to a bitmap.
6269
6270 //sdci[3]=sourcex
6271 //sdci[4]=sourcey
6272 //sdci[5]=sourcew
6273 //sdci[6]=sourceh
6274
6275 //sdci[7]=destw
6276 //sdci[8]=desth
6277 //sdci[9]=angle
6278 //scdi[10] = pivot cx
6279 //sdci[11] = pivot cy
6280 //sdci[12] = space Z
6281 //sdci[13] = horizon
6282 //scdi[14] = scale X
6283 //scdi[15] = scale Y
6284 //sdci[16] = masked?
6285 //sdci[17] Bitmap Pointer
6286
6287
6288
6289 // ZScript-side constant values:
6290 const int32_t BITDX_NORMAL = 0;
6291 const int32_t BITDX_TRANS = 1; //Translucent
6292 const int32_t BITDX_PIVOT = 2; //THe sprite will rotate at a specific point, instead of its center.
6293 const int32_t BITDX_HFLIP = 4; //Horizontal Flip
6294 const int32_t BITDX_VFLIP = 8; //Vertical Flip.
6295 //Note: Some modes cannot be combined. if a combination is not supported, an error
6296 // detailing this will be shown in allegro.log.
6297
6298 //scdi[15] = litcolour
6299 //The allegro docs are wrong. The params are: rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
6300 //not rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
6301
6302 //sdci[16]=mask
6303
6304 */
6305
6306
6307 int32_t bitmapIndex = sdci[2];
6308 int32_t usr_bitmap_index = sdci[2]-10;
6309 byte using_user_bitmap = 0;
6310 //Z_scripterrlog("bitmap index is: %d\n",bitmapIndex);
6311 //Z_scripterrlog("DrawPlane() bitmapIndex is: %d\n", bitmapIndex);
6312
6313 if ( bitmapIndex >= 10000 )
6314 {
6315 bitmapIndex = bitmapIndex / 10000; //reduce if ZScript sent a raw value, such as bitmap = <int32_t> 8;
6316 }
6317 else if ( usr_bitmap_index > 0 )
6318 {
6319 bitmapIndex = usr_bitmap_index;
6320 using_user_bitmap = 1;
6321 // Z_scripterrlog("Mode7 is using a user bitmap target, pointer: %d\n", usr_bitmap_index);
6322 yoffset = 0;
6323 }
6324
6325 //int32_t sx = sdci[3]/10000;
6326 //int32_t sy = sdci[4]/10000;
6327 //int32_t sw = sdci[5]/10000;
6328 //Z_scripterrlog("sh is: %d\n",sdci[5]/10000);
6329 //int32_t sh = sdci[6]/10000;
6330 //Z_scripterrlog("sh is: %d\n",sdci[6]/10000);
6331 //int32_t dx = sdci[7]/10000;
6332 //int32_t dy = sdci[8]/10000;
6333 //int32_t dw = sdci[9]/10000;
6334 //int32_t dh = sdci[10]/10000;
6335 //float rot = sdci[11]/10000;
6336 //int32_t cx = sdci[12]/10000;
6337 //int32_t cy = sdci[13]/10000;
6338 //int32_t mode = sdci[14]/10000;
6339 //int32_t litcolour = sdci[15]/10000;
6340
6341 //rendering mode 7 args
6342 double srcX = sdci[3]/10000.0;
6343 double srcY = sdci[4]/10000.0;
6344 double destX = sdci[5]/10000.0;
6345 double destY = sdci[6]/10000.0;
6346
6347
6348 // int32_t srcW = sdci[5]/10000;
6349 // int32_t srcH = sdci[6]/10000;
6350 double destW = sdci[7]/10000.0;
6351 double destH = sdci[8]/10000.0;
6352 // int32_t angle = sdci[9]/10000;
6353 // int32_t cx = sdci[10]/10000;
6354 // int32_t cy = sdci[11]/10000;
6355 double space_z = sdci[9]/10000.0;
6356 double horizon = sdci[10]/10000.0;
6357 double scale_x = sdci[11]/10000.0;
6358 double scale_y = sdci[12]/10000.0;
6359 byte masked = ( sdci[13] ) ? 1 : 0;
6360
6361
6362 int32_t ref = 0;
6363
6364 //dx = 0 + xoffset;
6365 //dy = 0 + yoffset;
6366
6367 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
6368 //Do we need to also check the render target and do the same thing if the
6369 //dest == -2 and the render target is not RT_SCREEN?
6370
6371 ref = sdci[17];
6372 //Z_scripterrlog("bitmap->DrawPlane() ref id this frame is: %d\n", ref);
6373 ref -=10;
6374 //Z_scripterrlog("bitmap->DrawPlane() modified ref id this frame is: %d\n", ref);
6375
6376
6377 if ( ref <= 0 )
6378 {
6379 Z_scripterrlog("bitmap->DrawPlane() wanted to use to an invalid source bitmap id: %d. Aborting.\n", ref);
6380 return;
6381 }
6382 BITMAP *sourceBitmap = FFCore.GetScriptBitmap(ref); //This can be the screen, as -1.
6383
6384 if(!sourceBitmap)
6385 {
6386 Z_message("Warning: %d->DrawPlane() source bitmap contains invalid data or is not initialized.\n", ref);
6387 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
6388 return;
6389 }
6390
6391 BITMAP *destBMP=NULL;
6392 //zprint2("mode 7 bitmap index is: %d\n",bitmapIndex);
6393 switch(bitmapIndex)
6394 {
6395 case -2:
6396 {
6397 int32_t curr_rt = zscriptDrawingRenderTarget->GetCurrentRenderTarget();
6398 //zprint2("current RT is: %d\n", curr_rt);
6399 if ( curr_rt >= 0 && curr_rt < 7 )
6400 destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); //Drawing to the current RenderTarget.
6401 else destBMP = bmp; //screen
6402 break;
6403 }
6404 case -1:
6405 destBMP = bmp; //this is framebuf, by default
6406 break;
6407 //zscriptDrawingRenderTarget->SetCurrentRenderTarget(bitmapIndex);
6408 //destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex);
6409 //destBMP = framebuf; //Drawing to the screen.
6410 //break;
6411
6412 //1 through 6 are the old system bitmaps (Render Targets)
6413 case 0:
6414 case 1:
6415 case 2:
6416 case 3:
6417 case 4:
6418 case 5:
6419 case 6:
6420 {
6421 //This gets a render target.
6422 //destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); break;
6423
6424 destBMP = zscriptDrawingRenderTarget->GetTargetBitmap(bitmapIndex);
6425 //sdci[18] = bitmapIndex;
6426 break;
6427 }
6428 //Otherwise, we are using a user-created bitmap, so, get that pointer insted.
6429 default:
6430 {
6431 destBMP = scb.script_created_bitmaps[usr_bitmap_index].u_bmp;
6432 //sdci[18] = usr_bitmap_index;
6433 if ( !scb.script_created_bitmaps[usr_bitmap_index].u_bmp )
6434 {
6435 Z_scripterrlog("Target for bitmap->DrawPlane is uninitialised. Aborting.\n");
6436 break;
6437 }
6438 }
6439 //FFCore.get_user_bitmap(bitmapIndex); break;
6440 }
6441
6442 if (!destBMP)
6443 {
6444 Z_message("Warning: DrawPlane(%d) destination bitmap contains invalid data or is not initialized.\n", bitmapIndex);
6445 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
6446 return;
6447 }
6448
6449 //dx = dx + xoffset; //don't do this here!
6450 //dy = dy + yoffset; //Nor this. It auto-offsets the bitmap by +56. Hmm. The fix that gleeok made isn't being applied to these functions. -Z ( 17th April, 2019 )
6451 //All of these are a factor of 10000 as fix.
6452 int32_t screen_x = 0; int32_t screen_y = 0;
6453
6454 double distance = 0; double horizontal_scale = 0;
6455
6456 int32_t screen_y_horizon = 0;
6457
6458 double line_dx = 0; double line_dy = 0;
6459
6460 int32_t space_x = 0; int32_t space_y = 0;
6461
6462 for(screen_y = 0; screen_y < destH; screen_y++) //fix, offset by .0000
6463 {
6464 //Calculate the distance of each line from the camera point
6465 screen_y_horizon = screen_y + horizon;
6466
6467 distance = ((space_z * scale_y) / ((screen_y_horizon != 0) ? screen_y_horizon : 1));
6468
6469 //Get the scale of each line based on the distance
6470
6471 horizontal_scale = (distance / (( scale_x != 0 ) ? scale_x : 1));
6472
6473 //There was some math here before I stripped out the rotation step
6474 line_dx = horizontal_scale;
6475 line_dy = 0;
6476
6477 //space_x,space_y - where to grab each scanline from on the space bitmap
6478 space_x = srcX - destW/2.0 * line_dx;
6479 space_y = srcY - distance + destH/2.0 * line_dy;
6480
6481 //Keep blits within the bounds of both bitmaps to avoid crashes
6482 int32_t y1 = srcY+space_y;
6483 int32_t y2 = destY+screen_y;
6484 if(y1 >=0 && y1 <= (sourceBitmap->h-1) && y2 >=0 && y2 <= (destBMP->h-1) )
6485 {
6486 if ( masked ) masked_stretch_blit(sourceBitmap, destBMP, (int32_t)(srcX+space_x), (int32_t)(srcY+space_y),
6487 (int32_t)(line_dx*destW), 1, (int32_t)(screen_x), (int32_t)(screen_y)+yoffset, (int32_t)(destW), 1);
6488 else stretch_blit(sourceBitmap, destBMP, (int32_t)(srcX+space_x), (int32_t)(srcY+space_y),
6489 (int32_t)(line_dx*destW), 1, (int32_t)(screen_x), (int32_t)(screen_y)+yoffset, (int32_t)(destW), 1);
6490 }
6491 }
6492 }
6493
6494
6495 //Draw]()
6496 236166 void bmp_do_drawbitmapexr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
6497 {
6498 /*
6499 //sdci[1]=layer
6500 //sdci[2]=bitmap target
6501 //
6502 // -2 is the current Render Target
6503 // -1, this is the screen (framebuf).
6504 // 0: Render target 0
6505 // 1: Render target 1
6506 // 2: Render target 2
6507 // 3: Render target 3
6508 // 4: Render target 4
6509 // 5: Render target 5
6510 // 6: Render target 6
6511 // Otherwise: The pointer to a bitmap.
6512
6513 //sdci[3]=sourcex
6514 //sdci[4]=sourcey
6515 //sdci[5]=sourcew
6516 //sdci[6]=sourceh
6517 //sdci[7]=destx
6518 //sdci[8]=desty
6519 //sdci[9]=destw
6520 //sdci[10]=desth
6521 //sdci[11]=rotation/angle
6522 //scdi[12] = pivot cx
6523 //sdci[13] = pivot cy
6524 //scdi[14] = effect flags
6525 //sdci[17] Bitmap Pointer
6526
6527 // ZScript-side constant values:
6528 const int32_t BITDX_NORMAL = 0;
6529 const int32_t BITDX_TRANS = 1; //Translucent
6530 const int32_t BITDX_PIVOT = 2; //THe sprite will rotate at a specific point, instead of its center.
6531 const int32_t BITDX_HFLIP = 4; //Horizontal Flip
6532 const int32_t BITDX_VFLIP = 8; //Vertical Flip.
6533 //Note: Some modes cannot be combined. if a combination is not supported, an error
6534 // detailing this will be shown in allegro.log.
6535
6536 //scdi[15] = litcolour
6537 //The allegro docs are wrong. The params are: rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
6538 //not rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
6539
6540 //sdci[16]=mask
6541
6542 */
6543
6544 236166 int32_t bitmapIndex = sdci[2]/10000;
6545 236166 int32_t usr_bitmap_index = sdci[2]-10;
6546 236166 byte using_user_bitmap = 0;
6547 //Z_scripterrlog("bitmap index is: %d\n",bitmapIndex);
6548 //Z_scripterrlog("Blit() bitmapIndex is: %d\n", bitmapIndex);
6549 #if LOG_BMPBLIT_LEVEL > 0
6550 Z_scripterrlog("Blit() found a dest bitmap ID of: %d\n",bitmapIndex);
6551 #endif
6552
1/2
✓ Branch 0 taken 236166 times.
✗ Branch 1 not taken.
236166 if ( bitmapIndex > 10000 )
6553 {
6554 bitmapIndex = bitmapIndex / 10000; //reduce if ZScript sent a raw value, such as bitmap = <int32_t> 8;
6555 }
6556
3/4
✓ Branch 0 taken 172223 times.
✓ Branch 1 taken 63943 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 172223 times.
236166 if ( usr_bitmap_index > 0 && usr_bitmap_index < 10000 )
6557 {
6558 172223 bitmapIndex = usr_bitmap_index;
6559 172223 using_user_bitmap = 1;
6560 172223 yoffset = 0;
6561 172223 }
6562
6563 236166 int32_t sx = sdci[3]/10000;
6564 236166 int32_t sy = sdci[4]/10000;
6565 236166 int32_t sw = sdci[5]/10000;
6566 //Z_scripterrlog("sh is: %d\n",sdci[5]/10000);
6567 236166 int32_t sh = sdci[6]/10000;
6568 //Z_scripterrlog("sh is: %d\n",sdci[6]/10000);
6569 236166 int32_t dx = sdci[7]/10000;
6570 236166 int32_t dy = sdci[8]/10000;
6571 236166 int32_t dw = sdci[9]/10000;
6572 236166 int32_t dh = sdci[10]/10000;
6573 236166 float rot = sdci[11]/10000;
6574 236166 int32_t cx = sdci[12]/10000;
6575 236166 int32_t cy = sdci[13]/10000;
6576 236166 int32_t mode = sdci[14]/10000;
6577 236166 int32_t litcolour = sdci[15]/10000;
6578 236166 bool masked = (sdci[16] != 0);
6579
6580 236166 int32_t ref = 0;
6581
6582 236166 dx = dx + xoffset;
6583 236166 dy = dy + yoffset;
6584
6585
2/4
✓ Branch 0 taken 236166 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 236166 times.
236166 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
6586 //Do we need to also check the render target and do the same thing if the
6587 //dest == -2 and the render target is not RT_SCREEN?
6588
6589 236166 ref = sdci[17];
6590 //Z_scripterrlog("bitmap->blit() ref id this frame is: %d\n", ref);
6591 236166 ref -=10;
6592 //Z_scripterrlog("bitmap->blit() modified ref id this frame is: %d\n", ref);
6593
6594
6595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236166 times.
236166 if ( ref <= 0 )
6596 {
6597 Z_scripterrlog("bitmap->blit() wanted to use to an invalid source bitmap id: %d. Aborting.\n", ref);
6598 return;
6599 }
6600 236166 BITMAP *sourceBitmap = FFCore.GetScriptBitmap(ref); //This can be the screen, as -1.
6601 #if LOG_BMPBLIT_LEVEL > 0
6602 Z_scripterrlog("bitmap->Blit() is trying to blit to ref: %d\n",sdci[17]);
6603 #endif
6604
1/2
✓ Branch 0 taken 236166 times.
✗ Branch 1 not taken.
236166 if(!sourceBitmap)
6605 {
6606
6607 Z_message("Warning: blit(%d) source bitmap contains invalid data or is not initialized.\n", ref);
6608 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
6609 return;
6610 }
6611
6612 236166 BITMAP *destBMP=NULL;
6613 //zprint2("blit () bitmap index is: %d\n",bitmapIndex);
6614
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 172223 times.
✓ Branch 2 taken 786 times.
✓ Branch 3 taken 63157 times.
236166 switch(bitmapIndex)
6615 {
6616 case -2:
6617 {
6618 786 int32_t curr_rt = zscriptDrawingRenderTarget->GetCurrentRenderTarget();
6619 //zprint2("current RT is: %d\n", curr_rt);
6620
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 786 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
786 if ( curr_rt >= 0 && curr_rt < 7 )
6621 destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); //Drawing to the current RenderTarget.
6622 786 else destBMP = bmp; //screen
6623 786 break;
6624 }
6625 case -1:
6626 63157 destBMP = bmp; //this is framebuf, by default
6627 63157 break;
6628 //zscriptDrawingRenderTarget->SetCurrentRenderTarget(bitmapIndex);
6629 //destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex);
6630 //destBMP = framebuf; //Drawing to the screen.
6631 //break;
6632
6633 //1 through 6 are the old system bitmaps (Render Targets)
6634 case 0:
6635 case 1:
6636 case 2:
6637 case 3:
6638 case 4:
6639 case 5:
6640 case 6:
6641 {
6642 //This gets a render target.
6643 destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); break;
6644
6645 //destBMP = zscriptDrawingRenderTarget->GetTargetBitmap(bitmapIndex);
6646 //sdci[18] = bitmapIndex;
6647 break;
6648 }
6649 //Otherwise, we are using a user-created bitmap, so, get that pointer insted.
6650 default:
6651 {
6652 172223 destBMP = scb.script_created_bitmaps[usr_bitmap_index].u_bmp;
6653 //sdci[18] = usr_bitmap_index;
6654
1/2
✓ Branch 0 taken 172223 times.
✗ Branch 1 not taken.
172223 if ( !scb.script_created_bitmaps[usr_bitmap_index].u_bmp )
6655 {
6656 Z_scripterrlog("Target for bitmap->Blit is uninitialised. Aborting.\n");
6657 break;
6658 }
6659 }
6660 //FFCore.get_user_bitmap(bitmapIndex); break;
6661 172223 }
6662
6663
6664
6665 #if LOG_BMPBLIT_LEVEL > 0
6666 Z_scripterrlog("bitmap->Blit() is trying to blit to dest bitmap ID: %d\n",bitmapIndex);
6667 #endif
6668
6669
6670
1/2
✓ Branch 0 taken 236166 times.
✗ Branch 1 not taken.
236166 if (!destBMP)
6671 {
6672
6673 Z_message("Warning: blit(%d) destination bitmap contains invalid data or is not initialized.\n", bitmapIndex);
6674 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
6675 return;
6676 }
6677
6678 //bugfix
6679 //sx = vbound(sx, 0, sourceBitmap->w);
6680 #if LOG_BMPBLIT_LEVEL > 0
6681 Z_scripterrlog("Blit %s is: %d\n", "sx", sx);
6682 Z_scripterrlog("Blit %s is: %d\n", "source->w", sourceBitmap->w);
6683 #endif
6684 //sy = vbound(sy, 0, sourceBitmap->h);
6685 #if LOG_BMPBLIT_LEVEL > 0
6686 Z_scripterrlog("Blit %s is: %d\n", "sy", sy);
6687 Z_scripterrlog("Blit %s is: %d\n", "source->h", sourceBitmap->h);
6688 #endif
6689 //sw = vbound(sw, 0, sourceBitmap->w - sx); //keep the w/h within range as well
6690 #if LOG_BMPBLIT_LEVEL > 0
6691 Z_scripterrlog("Blit %s is: %d\n", "sw", sw);
6692 #endif
6693 //sh = vbound(sh, 0, sourceBitmap->h - sy);
6694 #if LOG_BMPBLIT_LEVEL > 0
6695 Z_scripterrlog("Blit %s is: %d\n", "sh", sh);
6696
6697 Z_scripterrlog("Blit %s is: %d\n", "dh", dh);
6698 Z_scripterrlog("Blit %s is: %d\n", "dw", dw);
6699 #endif
6700
2/2
✓ Branch 0 taken 1027 times.
✓ Branch 1 taken 235139 times.
236166 bool stretched = (sw != dw || sh != dh);
6701 //bool stretched = (sourceBitmap->w != destBMP->w || sourceBitmap->h != destBMP->h);
6702 #if LOG_BMPBLIT_LEVEL > 0
6703 Z_scripterrlog("Blit %s is: %s\n", "stretched", stretched ? "true" : "false");
6704 #endif
6705 //BITMAP *sourceBitmap = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex);
6706
6707
6708
6709
6710
6711 236166 BITMAP* subBmp = 0;
6712
6713 /* IDR what this was. -Z ( 17th April, 2019 )
6714 if ( bitmapIndex == -1 ) {
6715 blit(bmp, sourceBitmap, sx, sy, 0, 0, dw, dh);
6716 }
6717 */
6718
6719
4/4
✓ Branch 0 taken 234587 times.
✓ Branch 1 taken 1579 times.
✓ Branch 2 taken 24951 times.
✓ Branch 3 taken 209636 times.
236166 if(rot != 0 || mode != 0)
6720 {
6721 26530 subBmp = create_bitmap_ex(8,sourceBitmap->w, sourceBitmap->h);//script_drawing_commands.AquireSubBitmap(dw, dh);
6722 26530 clear_bitmap(subBmp);
6723
6724
1/2
✓ Branch 0 taken 26530 times.
✗ Branch 1 not taken.
26530 if(!subBmp)
6725 {
6726
6727 Z_scripterrlog("bitmap->Blit failed to create a sub-bitmap to use for %s. Aborting.\n", "rotation");
6728 return;
6729 }
6730 26530 }
6731 236166 BITMAP* sbmp = sourceBitmap;
6732
2/4
✓ Branch 0 taken 236166 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 236166 times.
236166 if (sx + sw > sbmp->w || sy + sh > sbmp->h)
6733 {
6734 sbmp = create_bitmap_ex(8, sw, sh);
6735 clear_bitmap(sbmp);
6736 blit(sourceBitmap, sbmp, sx, sy, 0, 0, std::min(sourceBitmap->w-sx, sw), std::min(sourceBitmap->h-sy, sh));
6737 sx = 0;
6738 sy = 0;
6739 }
6740 //dx = dx + xoffset; //don't do this here!
6741 //dy = dy + yoffset; //Nor this. It auto-offsets the bitmap by +56. Hmm. The fix that gleeok made isn't being applied to these functions. -Z ( 17th April, 2019 )
6742
6743
2/2
✓ Branch 0 taken 1602 times.
✓ Branch 1 taken 234564 times.
236166 if(stretched)
6744 {
6745
2/2
✓ Branch 0 taken 1475 times.
✓ Branch 1 taken 127 times.
1602 if(masked)
6746 { //stretched and masked
6747
2/2
✓ Branch 0 taken 574 times.
✓ Branch 1 taken 901 times.
1475 if ( rot == 0 )
6748 { //if not rotated
6749
2/22
✗ Branch 0 not taken.
✓ Branch 1 taken 900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 1 times.
901 switch(mode)
6750 {
6751 case 1:
6752 //transparent
6753 900 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6754 900 draw_trans_sprite(destBMP, subBmp, dx, dy);
6755 900 break;
6756
6757
6758 case 2:
6759 //pivot?
6760 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6761 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
6762 //Pivoting requires two more args
6763 break;
6764
6765 case 3:
6766 //pivot + trans
6767 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6768 pivot_sprite_trans(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
6769 break;
6770
6771 case 4:
6772 //flip v
6773 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6774 draw_sprite_v_flip(destBMP, subBmp, dx, dy);
6775 break;
6776
6777 case 5:
6778 //trans + v flip
6779 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6780 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
6781 break;
6782
6783 case 6:
6784 //pivot + v flip
6785 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6786 pivot_sprite_v_flip(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
6787 break;
6788
6789 case 8:
6790 //vlip h
6791 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6792 draw_sprite_h_flip(destBMP, subBmp, dx, dy);
6793 break;
6794
6795 case 9:
6796 //trans + h flip
6797 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6798 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
6799 break;
6800
6801 case 10:
6802 //flip H and pivot
6803 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
6804 //return error cannot pivot and h flip
6805 break;
6806
6807 case 12:
6808 //vh flip
6809 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6810 draw_sprite_vh_flip(destBMP, subBmp, dx, dy);
6811 break;
6812
6813 case 13:
6814 //trans + vh flip
6815 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6816 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
6817 break;
6818
6819 case 14:
6820 //pivot and vh flip
6821 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
6822 //return error cannot both pivot and vh flip
6823 break;
6824
6825 case 16:
6826 //lit
6827 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6828 draw_lit_sprite(destBMP, subBmp, dx, dy, litcolour);
6829 break;
6830
6831 case 18:
6832 //pivot, lit
6833 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6834 pivot_sprite_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
6835 break;
6836
6837 case 20:
6838 //lit + v flip
6839 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6840 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
6841 break;
6842
6843 case 22:
6844 //Pivot, vflip, lit
6845 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6846 pivot_sprite_v_flip_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
6847 break;
6848
6849 case 24:
6850 //lit + h flip
6851 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6852 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
6853 break;
6854
6855 case 26:
6856 //pivot + lit + hflip
6857 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
6858 //return error cannot pivot, lit, and flip
6859 break;
6860
6861 case 28:
6862 //lit + vh flip
6863 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6864 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
6865 break;
6866
6867 case 32: //gouraud
6868 //Probably not wort supporting.
6869 //masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6870 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
6871 break;
6872
6873 case 0:
6874 //no effect
6875 1 masked_stretch_blit(sbmp, destBMP, sx, sy, sw, sh, dx, dy, dw, dh);
6876 1 break;
6877
6878
6879 default:
6880
6881 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
6882
6883
6884 }
6885 901 } //end if not rotated
6886
6887
2/2
✓ Branch 0 taken 901 times.
✓ Branch 1 taken 574 times.
1475 if ( rot != 0 ) //if rotated
6888 {
6889
1/22
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 574 times.
✗ Branch 21 not taken.
574 switch(mode)
6890 {
6891 case 1:
6892 //transparent
6893 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6894 rotate_sprite_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
6895
6896 break;
6897
6898 case 2:
6899 //pivot?
6900 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6901 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
6902 //Pivoting requires two more args
6903 break;
6904
6905 case 3:
6906 //pivot + trans
6907 //return an error, cannot both rotate and pivot
6908 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
6909 break;
6910
6911 case 4:
6912 //flip v
6913 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6914 rotate_sprite_v_flip(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
6915 break;
6916
6917 case 5:
6918 //trans + v flip
6919 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6920 rotate_sprite_v_flip_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
6921 break;
6922
6923 case 6:
6924 //pivot + v flip
6925 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
6926 //return an error, cannot both rotate and pivot
6927 break;
6928
6929 case 8:
6930 //flip h
6931 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
6932 //return an error, cannot both rotate and flip H
6933 break;
6934
6935 case 9:
6936 //trans + h flip
6937 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
6938 //return an error, cannot rotate and flip a trans sprite
6939 break;
6940
6941 case 10:
6942 //flip H and pivot
6943 //return error cannot pivot and h flip
6944 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
6945 break;
6946
6947 case 12:
6948 //vh flip
6949 //return an error, cannot rotate and VH flip a trans sprite
6950 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
6951 break;
6952
6953 case 13:
6954 //trans + vh flip
6955 //return an error, cannot rotate and VH flip a trans sprite
6956 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
6957 break;
6958
6959 case 14:
6960 //pivot and vh flip
6961 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
6962 //return error cannot both pivot and vh flip
6963 break;
6964
6965 case 16:
6966 //lit
6967 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6968 rotate_sprite_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
6969 break;
6970
6971 case 18:
6972 //pivot, lit
6973 //return an error, cannot both rotate and pivot
6974 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
6975 break;
6976
6977 case 20:
6978 //lit + vflip
6979 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6980 rotate_sprite_v_flip_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
6981 break;
6982
6983 case 22:
6984 //Pivot, vflip, lit
6985 //return an error, cannot both rotate and pivot
6986 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
6987 break;
6988
6989 case 24:
6990 //lit + h flip
6991 //return an error, cannot both rotate and H flip
6992 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
6993 break;
6994
6995 case 26:
6996 //pivot + lit + hflip
6997 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
6998 //return error cannot pivot, lit, and flip
6999 break;
7000
7001 case 28:
7002 //lit + vh flip
7003 //return an error, cannot both rotate and VH flip
7004 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
7005 break;
7006
7007 case 32: //gouraud
7008 //Probably not wort supporting.
7009 //masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7010 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
7011 break;
7012
7013 case 0:
7014 //no effect.
7015 574 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7016 574 rotate_sprite(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7017 574 break;
7018
7019 default:
7020
7021 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
7022
7023 }
7024 574 }
7025 1475 } //end if stretched and masked
7026
7027 else //stretched, not masked
7028 {
7029
7030
7031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 if ( rot == 0 ) //if not rotated
7032 {
7033
1/22
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 127 times.
127 switch(mode)
7034 {
7035 case 1:
7036 //transparent
7037 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7038 draw_trans_sprite(destBMP, subBmp, dx, dy);
7039 break;
7040
7041
7042 case 2:
7043 //pivot?
7044 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7045 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7046 //Pivoting requires two more args
7047 break;
7048
7049 case 3:
7050 //pivot + trans
7051 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7052 pivot_sprite_trans(destBMP, subBmp, dx,dy, cx, cy, degrees_to_fixed(rot));
7053 break;
7054
7055 case 4:
7056 //flip v
7057 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7058 draw_sprite_v_flip(destBMP, subBmp, dx, dy);
7059 break;
7060
7061 case 5:
7062 //trans + v flip
7063 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7064 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
7065 break;
7066
7067 case 6:
7068 //pivot + v flip
7069 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7070 pivot_sprite_v_flip(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7071 break;
7072
7073 case 8:
7074 //vlip h
7075 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7076 draw_sprite_h_flip(destBMP, subBmp, dx, dy);
7077 break;
7078
7079 case 9:
7080 //trans + h flip
7081 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7082 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
7083 break;
7084
7085 case 10:
7086 //flip H and pivot
7087 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
7088 //return error cannot pivot and h flip
7089 break;
7090
7091 case 12:
7092 //vh flip
7093 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7094 draw_sprite_vh_flip(destBMP, subBmp, dx, dy);
7095 break;
7096
7097 case 13:
7098 //trans + vh flip
7099 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7100 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
7101 break;
7102
7103 case 14:
7104 //pivot and vh flip
7105 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
7106 //return error cannot both pivot and vh flip
7107 break;
7108
7109 case 16:
7110 //lit
7111 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7112 draw_lit_sprite(destBMP, subBmp, dx, dy, litcolour);
7113 break;
7114
7115 case 18:
7116 //pivot, lit
7117 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7118 pivot_sprite_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
7119 break;
7120
7121 case 20:
7122 //lit + v flip
7123 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7124 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
7125 break;
7126
7127 case 22:
7128 //Pivot, vflip, lit
7129 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7130 pivot_sprite_v_flip_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
7131 break;
7132
7133 case 24:
7134 //lit + h flip
7135 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7136 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
7137 break;
7138
7139 case 26:
7140 //pivot + lit + hflip
7141 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
7142 //return error cannot pivot, lit, and flip
7143 break;
7144
7145 case 28:
7146 //lit + vh flip
7147 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7148 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
7149 break;
7150
7151 case 32: //gouraud
7152 //Probably not wort supporting.
7153 //stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7154 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
7155 break;
7156
7157 case 0:
7158 //no effect
7159 127 stretch_blit(sbmp, destBMP, sx, sy, sw, sh, dx, dy, dw, dh);
7160 127 break;
7161
7162
7163 default:
7164
7165 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
7166
7167
7168 }
7169 127 } //end if not rotated
7170
7171
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if ( rot != 0 ) //if rotated
7172 {
7173 switch(mode)
7174 {
7175 case 1:
7176 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
7177 rotate_sprite_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7178
7179 break;
7180
7181 case 2:
7182 //pivot?
7183 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7184 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7185 //Pivoting requires two more args
7186 break;
7187
7188 case 3:
7189 //pivot + trans
7190 //return an error, cannot both rotate and pivot
7191 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7192 break;
7193
7194 case 4:
7195 //flip v
7196 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7197 rotate_sprite_v_flip(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7198 break;
7199
7200 case 5:
7201 //trans + v flip
7202 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7203 rotate_sprite_v_flip_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7204 break;
7205
7206 case 6:
7207 //pivot + v flip
7208 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7209 //return an error, cannot both rotate and pivot
7210 break;
7211
7212 case 8:
7213 //flip h
7214 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
7215 //return an error, cannot both rotate and flip H
7216 break;
7217
7218 case 9:
7219 //trans + h flip
7220 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
7221 //return an error, cannot rotate and flip a trans sprite
7222 break;
7223
7224 case 10:
7225 //flip H and pivot
7226 //return error cannot pivot and h flip
7227 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
7228 break;
7229
7230 case 12:
7231 //vh flip
7232 //return an error, cannot rotate and VH flip a trans sprite
7233 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
7234 break;
7235
7236 case 13:
7237 //trans + vh flip
7238 //return an error, cannot rotate and VH flip a trans sprite
7239 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
7240 break;
7241
7242 case 14:
7243 //pivot and vh flip
7244 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
7245 //return error cannot both pivot and vh flip
7246 break;
7247
7248 case 16:
7249 //lit
7250 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
7251 rotate_sprite_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7252 break;
7253
7254 case 18:
7255 //pivot, lit
7256 //return an error, cannot both rotate and pivot
7257 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7258 break;
7259
7260 case 20:
7261 //lit + vflip
7262 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
7263 rotate_sprite_v_flip_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7264 break;
7265
7266 case 22:
7267 //Pivot, vflip, lit
7268 //return an error, cannot both rotate and pivot
7269 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
7270 break;
7271
7272 case 24:
7273 //lit + h flip
7274 //return an error, cannot both rotate and H flip
7275 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
7276 break;
7277
7278 case 26:
7279 //pivot + lit + hflip
7280 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
7281 //return error cannot pivot, lit, and flip
7282 break;
7283
7284 case 28:
7285 //lit + vh flip
7286 //return an error, cannot both rotate and VH flip
7287 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
7288 break;
7289
7290 case 32: //gouraud
7291 //Probably not wort supporting.
7292 //stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7293 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
7294 break;
7295
7296 case 0:
7297 //no effect.
7298 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7299 rotate_sprite(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7300 break;
7301
7302 default:
7303
7304 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
7305
7306 }
7307 }
7308
7309 } //end if stretched, but not masked
7310 1602 }
7311 else //not stretched
7312 {
7313
7314
2/2
✓ Branch 0 taken 223581 times.
✓ Branch 1 taken 10983 times.
234564 if(masked) //if masked, but not stretched
7315 {
7316
7317
2/2
✓ Branch 0 taken 1005 times.
✓ Branch 1 taken 222576 times.
223581 if ( rot == 0 ) //if not rotated
7318 {
7319
2/22
✗ Branch 0 not taken.
✓ Branch 1 taken 18657 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 203919 times.
222576 switch(mode)
7320 {
7321 case 1:
7322 //transparent
7323 18657 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7324 18657 draw_trans_sprite(destBMP, subBmp, dx, dy);
7325 18657 break;
7326
7327
7328 case 2:
7329 //pivot?
7330 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7331 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7332 //Pivoting requires two more args
7333 break;
7334
7335 case 3:
7336 //pivot + trans
7337 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7338 pivot_sprite_trans(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7339 break;
7340
7341 case 4:
7342 //flip v
7343 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7344 draw_sprite_v_flip(destBMP, subBmp, dx, dy);
7345 break;
7346
7347 case 5:
7348 //trans + v flip
7349 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7350 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
7351 break;
7352
7353 case 6:
7354 //pivot + v flip
7355 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7356 pivot_sprite_v_flip(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7357 break;
7358
7359 case 8:
7360 //vlip h
7361 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7362 draw_sprite_h_flip(destBMP, subBmp, dx, dy);
7363 break;
7364
7365 case 9:
7366 //trans + h flip
7367 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7368 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
7369 break;
7370
7371 case 10:
7372 //flip H and pivot
7373 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
7374 //return error cannot pivot and h flip
7375 break;
7376
7377 case 12:
7378 //vh flip
7379 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7380 draw_sprite_vh_flip(destBMP, subBmp, dx, dy);
7381 break;
7382
7383 case 13:
7384 //trans + vh flip
7385 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7386 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
7387 break;
7388
7389 case 14:
7390 //pivot and vh flip
7391 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
7392 //return error cannot both pivot and vh flip
7393 break;
7394
7395 case 16:
7396 //lit
7397 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7398 draw_lit_sprite(destBMP, subBmp, dx, dy, litcolour);
7399 break;
7400
7401 case 18:
7402 //pivot, lit
7403 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7404 pivot_sprite_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
7405 break;
7406
7407 case 20:
7408 //lit + v flip
7409 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7410 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
7411 break;
7412
7413 case 22:
7414 //Pivot, vflip, lit
7415 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7416 pivot_sprite_v_flip_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
7417 break;
7418
7419 case 24:
7420 //lit + h flip
7421 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7422 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
7423 break;
7424
7425 case 26:
7426 //pivot + lit + hflip
7427 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
7428 //return error cannot pivot, lit, and flip
7429 break;
7430
7431 case 28:
7432 //lit + vh flip
7433 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7434 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
7435 break;
7436
7437 case 32: //gouraud
7438 //Probably not wort supporting.
7439 //stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7440 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
7441 break;
7442
7443 case 0:
7444 //no effect
7445 203919 masked_blit(sbmp, destBMP, sx, sy, dx, dy, dw, dh);
7446 203919 break;
7447
7448
7449 default:
7450
7451 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
7452
7453
7454 }
7455 222576 } //end if not rotated
7456
7457
2/2
✓ Branch 0 taken 222576 times.
✓ Branch 1 taken 1005 times.
223581 if ( rot != 0 ) //if rotated
7458 {
7459
1/22
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 1005 times.
✗ Branch 21 not taken.
1005 switch(mode)
7460 {
7461 case 1:
7462 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); //transparent
7463 rotate_sprite_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7464
7465 break;
7466
7467 case 2:
7468 //pivot?
7469 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7470 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7471 //Pivoting requires two more args
7472 break;
7473
7474 case 3:
7475 //pivot + trans
7476 //return an error, cannot both rotate and pivot
7477 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7478 break;
7479
7480 case 4:
7481 //flip v
7482 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7483 rotate_sprite_v_flip(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7484 break;
7485
7486 case 5:
7487 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); //trans + v flip
7488 rotate_sprite_v_flip_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7489 break;
7490
7491 case 6:
7492 //pivot + v flip
7493 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7494 //return an error, cannot both rotate and pivot
7495 break;
7496
7497 case 8:
7498 //flip h
7499 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
7500 //return an error, cannot both rotate and flip H
7501 break;
7502
7503 case 9:
7504 //trans + h flip
7505 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
7506 //return an error, cannot rotate and flip a trans sprite
7507 break;
7508
7509 case 10:
7510 //flip H and pivot
7511 //return error cannot pivot and h flip
7512 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
7513 break;
7514
7515 case 12:
7516 //vh flip
7517 //return an error, cannot rotate and VH flip a trans sprite
7518 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
7519 break;
7520
7521 case 13:
7522 //trans + vh flip
7523 //return an error, cannot rotate and VH flip a trans sprite
7524 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
7525 break;
7526
7527 case 14:
7528 //pivot and vh flip
7529 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
7530 //return error cannot both pivot and vh flip
7531 break;
7532
7533 case 16:
7534 //lit
7535 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7536 rotate_sprite_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7537 break;
7538
7539 case 18:
7540 //pivot, lit
7541 //return an error, cannot both rotate and pivot
7542 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7543 break;
7544
7545 case 20:
7546 //lit + vflip
7547 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7548 rotate_sprite_v_flip_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7549 break;
7550
7551 case 22:
7552 //Pivot, vflip, lit
7553 //return an error, cannot both rotate and pivot
7554 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
7555 break;
7556
7557 case 24:
7558 //lit + h flip
7559 //return an error, cannot both rotate and H flip
7560 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
7561 break;
7562
7563 case 26:
7564 //pivot + lit + hflip
7565 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
7566 //return error cannot pivot, lit, and flip
7567 break;
7568
7569 case 28:
7570 //lit + vh flip
7571 //return an error, cannot both rotate and VH flip
7572 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
7573 break;
7574
7575 case 32: //gouraud
7576 //Probably not wort supporting.
7577 //stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7578 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
7579 break;
7580
7581 case 0:
7582 //no effect.
7583 1005 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7584 1005 rotate_sprite(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7585 1005 break;
7586
7587 default:
7588
7589 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
7590
7591 }
7592 1005 } //end rtated, masked
7593 223581 } //end if masked
7594
7595 else //not masked, and not stretched; just blit
7596 {
7597
7598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10983 times.
10983 if ( rot == 0 ) //if not rotated
7599 {
7600
2/22
✗ Branch 0 not taken.
✓ Branch 1 taken 5394 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 5589 times.
10983 switch(mode)
7601 {
7602 case 1:
7603 //transparent
7604 5394 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7605 5394 draw_trans_sprite(destBMP, subBmp, dx, dy);
7606 5394 break;
7607
7608
7609 case 2:
7610 //pivot?
7611 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7612 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7613 //Pivoting requires two more args
7614 break;
7615
7616 case 3:
7617 //pivot + trans
7618 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7619 pivot_sprite_trans(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7620 break;
7621
7622 case 4:
7623 //flip v
7624 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7625 draw_sprite_v_flip(destBMP, subBmp, dx, dy);
7626 break;
7627
7628 case 5:
7629 //trans + v flip
7630 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7631 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
7632 break;
7633
7634 case 6:
7635 //pivot + v flip
7636 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7637 pivot_sprite_v_flip(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7638 break;
7639
7640 case 8:
7641 //vlip h
7642 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7643 draw_sprite_h_flip(destBMP, subBmp, dx, dy);
7644 break;
7645
7646 case 9:
7647 //trans + h flip
7648 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7649 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
7650 break;
7651
7652 case 10:
7653 //flip H and pivot
7654 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
7655 //return error cannot pivot and h flip
7656 break;
7657
7658 case 12:
7659 //vh flip
7660 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7661 draw_sprite_vh_flip(destBMP, subBmp, dx, dy);
7662 break;
7663
7664 case 13:
7665 //trans + vh flip
7666 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7667 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
7668 break;
7669
7670 case 14:
7671 //pivot and vh flip
7672 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
7673 //return error cannot both pivot and vh flip
7674 break;
7675
7676 case 16:
7677 //lit
7678 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7679 draw_lit_sprite(destBMP, subBmp, dx, dy, litcolour);
7680 break;
7681
7682 case 18:
7683 //pivot, lit
7684 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7685 pivot_sprite_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
7686 break;
7687
7688 case 20:
7689 //lit + v flip
7690 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7691 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
7692 break;
7693
7694 case 22:
7695 //Pivot, vflip, lit
7696 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7697 pivot_sprite_v_flip_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
7698 break;
7699
7700 case 24:
7701 //lit + h flip
7702 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7703 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
7704 break;
7705
7706 case 26:
7707 //pivot + lit + hflip
7708 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
7709 //return error cannot pivot, lit, and flip
7710 break;
7711
7712 case 28:
7713 //lit + vh flip
7714 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7715 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
7716 break;
7717
7718 case 32: //gouraud
7719 //Probably not wort supporting.
7720 //blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7721 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
7722 break;
7723
7724 case 0:
7725 //no effect
7726 5589 blit(sbmp, destBMP, sx, sy, dx, dy, dw, dh);
7727 5589 break;
7728
7729
7730 default:
7731
7732 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
7733
7734
7735 }
7736 10983 } //end if not rotated
7737
7738
1/2
✓ Branch 0 taken 10983 times.
✗ Branch 1 not taken.
10983 if ( rot != 0 ) //if rotated
7739 {
7740 switch(mode)
7741 {
7742 case 1:
7743 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);//transparent
7744 rotate_sprite_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7745
7746 break;
7747
7748 case 2:
7749 //pivot?
7750 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7751 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7752 //Pivoting requires two more args
7753 break;
7754
7755 case 3:
7756 //pivot + trans
7757 //return an error, cannot both rotate and pivot
7758 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7759 break;
7760
7761 case 4:
7762 //flip v
7763 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7764 rotate_sprite_v_flip(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7765 break;
7766
7767 case 5:
7768 //trans + v flip
7769 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7770 rotate_sprite_v_flip_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7771 break;
7772
7773 case 6:
7774 //pivot + v flip
7775 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7776 //return an error, cannot both rotate and pivot
7777 break;
7778
7779 case 8:
7780 //flip h
7781 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
7782 //return an error, cannot both rotate and flip H
7783 break;
7784
7785 case 9:
7786 //trans + h flip
7787 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
7788 //return an error, cannot rotate and flip a trans sprite
7789 break;
7790
7791 case 10:
7792 //flip H and pivot
7793 //return error cannot pivot and h flip
7794 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
7795 break;
7796
7797 case 12:
7798 //vh flip
7799 //return an error, cannot rotate and VH flip a trans sprite
7800 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
7801 break;
7802
7803 case 13:
7804 //trans + vh flip
7805 //return an error, cannot rotate and VH flip a trans sprite
7806 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
7807 break;
7808
7809 case 14:
7810 //pivot and vh flip
7811 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
7812 //return error cannot both pivot and vh flip
7813 break;
7814
7815 case 16:
7816 //lit
7817 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7818 rotate_sprite_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7819 break;
7820
7821 case 18:
7822 //pivot, lit
7823 //return an error, cannot both rotate and pivot
7824 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7825 break;
7826
7827 case 20:
7828 //lit + vflip
7829 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7830 rotate_sprite_v_flip_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7831 break;
7832
7833 case 22:
7834 //Pivot, vflip, lit
7835 //return an error, cannot both rotate and pivot
7836 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
7837 break;
7838
7839 case 24:
7840 //lit + h flip
7841 //return an error, cannot both rotate and H flip
7842 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
7843 break;
7844
7845 case 26:
7846 //pivot + lit + hflip
7847 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
7848 //return error cannot pivot, lit, and flip
7849 break;
7850
7851 case 28:
7852 //lit + vh flip
7853 //return an error, cannot both rotate and VH flip
7854 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
7855 break;
7856
7857 case 32: //gouraud
7858 //Probably not wort supporting.
7859 //blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7860 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
7861 break;
7862
7863 case 0:
7864 //no effect.
7865 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7866 rotate_sprite(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7867 break;
7868
7869 default:
7870
7871 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
7872
7873 }
7874 } //end if rotated
7875 } //end if not masked
7876 } //end if not stretched
7877
7878 //cleanup
7879
2/2
✓ Branch 0 taken 26530 times.
✓ Branch 1 taken 209636 times.
236166 if(subBmp)
7880 {
7881 //script_drawing_commands.ReleaseSubBitmap(subBmp); //purge the temporary bitmap.
7882 26530 destroy_bitmap(subBmp);
7883 26530 }
7884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236166 times.
236166 if (sbmp != sourceBitmap)
7885 {
7886 destroy_bitmap(sbmp);
7887 }
7888 236166 }
7889
7890
7891
7892 909 void bmp_do_blittor(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
7893 {
7894 /*
7895 //sdci[1]=layer
7896 //sdci[2]=bitmap target
7897 //
7898 // -2 is the current Render Target
7899 // -1, this is the screen (framebuf).
7900 // 0: Render target 0
7901 // 1: Render target 1
7902 // 2: Render target 2
7903 // 3: Render target 3
7904 // 4: Render target 4
7905 // 5: Render target 5
7906 // 6: Render target 6
7907 // Otherwise: The pointer to a bitmap.
7908
7909 //sdci[3]=sourcex
7910 //sdci[4]=sourcey
7911 //sdci[5]=sourcew
7912 //sdci[6]=sourceh
7913 //sdci[7]=destx
7914 //sdci[8]=desty
7915 //sdci[9]=destw
7916 //sdci[10]=desth
7917 //sdci[11]=rotation/angle
7918 //scdi[12] = pivot cx
7919 //sdci[13] = pivot cy
7920 //scdi[14] = effect flags
7921 //sdci[17] Bitmap Pointer
7922
7923 // ZScript-side constant values:
7924 const int32_t BITDX_NORMAL = 0;
7925 const int32_t BITDX_TRANS = 1; //Translucent
7926 const int32_t BITDX_PIVOT = 2; //THe sprite will rotate at a specific point, instead of its center.
7927 const int32_t BITDX_HFLIP = 4; //Horizontal Flip
7928 const int32_t BITDX_VFLIP = 8; //Vertical Flip.
7929 //Note: Some modes cannot be combined. if a combination is not supported, an error
7930 // detailing this will be shown in allegro.log.
7931
7932 //scdi[15] = litcolour
7933 //The allegro docs are wrong. The params are: rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7934 //not rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
7935
7936 //sdci[16]=mask
7937
7938 */
7939
7940 909 int32_t srcyoffset = yoffset, srcxoffset = xoffset;
7941 909 int32_t bitmapIndex = sdci[2]/10000;
7942 909 int32_t usr_bitmap_index = sdci[2]-10;
7943 909 byte using_user_bitmap = 0;
7944 //Z_scripterrlog("bitmap index is: %d\n",bitmapIndex);
7945 //Z_scripterrlog("Blit() bitmapIndex is: %d\n", bitmapIndex);
7946 #if LOG_BMPBLIT_LEVEL > 0
7947 Z_scripterrlog("Blit() found a dest bitmap ID of: %d\n",bitmapIndex);
7948 #endif
7949
1/2
✓ Branch 0 taken 909 times.
✗ Branch 1 not taken.
909 if ( bitmapIndex > 10000 )
7950 {
7951 bitmapIndex = bitmapIndex / 10000; //reduce if ZScript sent a raw value, such as bitmap = <int32_t> 8;
7952 }
7953
3/4
✓ Branch 0 taken 906 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 906 times.
909 if ( usr_bitmap_index > 0 && usr_bitmap_index < 10000 )
7954 {
7955 906 bitmapIndex = usr_bitmap_index;
7956 906 using_user_bitmap = 1;
7957 906 srcyoffset = 0;
7958 906 }
7959
7960 909 int32_t sx = sdci[3]/10000;
7961 909 int32_t sy = sdci[4]/10000;
7962 909 int32_t sw = sdci[5]/10000;
7963 //Z_scripterrlog("sh is: %d\n",sdci[5]/10000);
7964 909 int32_t sh = sdci[6]/10000;
7965 //Z_scripterrlog("sh is: %d\n",sdci[6]/10000);
7966 909 int32_t dx = sdci[7]/10000;
7967 909 int32_t dy = sdci[8]/10000;
7968 909 int32_t dw = sdci[9]/10000;
7969 909 int32_t dh = sdci[10]/10000;
7970 909 float rot = sdci[11]/10000;
7971 909 int32_t cx = sdci[12]/10000;
7972 909 int32_t cy = sdci[13]/10000;
7973 909 int32_t mode = sdci[14]/10000;
7974 909 int32_t litcolour = sdci[15]/10000;
7975 909 bool masked = (sdci[16] != 0);
7976
7977 909 int32_t ref = 0;
7978
7979 //These should go down farther, should they not? -V
7980 //dx = dx + xoffset;
7981 //dy = dy + yoffset;
7982
7983
2/4
✓ Branch 0 taken 909 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 909 times.
909 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
7984
3/4
✓ Branch 0 taken 909 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 906 times.
909 if ( (bitmapIndex) != -2 && (bitmapIndex) != -1 ) srcyoffset = 0; //Don't crop.
7985 //Do we need to also check the render target and do the same thing if the
7986 //dest == -2 and the render target is not RT_SCREEN?
7987 909 dx = dx + xoffset;
7988 909 dy = dy + yoffset;
7989 909 sx = sx + srcxoffset;
7990 909 sy = sy + srcyoffset;
7991
7992 909 ref = sdci[17];
7993 //Z_scripterrlog("bitmap->blit() ref id this frame is: %d\n", ref);
7994 909 ref -=10;
7995 //Z_scripterrlog("bitmap->blit() modified ref id this frame is: %d\n", ref);
7996
7997
7998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 909 times.
909 if ( ref <= 0 )
7999 {
8000 Z_scripterrlog("bitmap->blit() wanted to use to an invalid source bitmap id: %d. Aborting.\n", ref);
8001 return;
8002 }
8003 909 BITMAP *sourceBitmap = FFCore.GetScriptBitmap(ref); //This can be the screen, as -1.
8004 #if LOG_BMPBLIT_LEVEL > 0
8005 Z_scripterrlog("bitmap->Blit() is trying to blit to ref: %d\n",sdci[17]);
8006 #endif
8007
1/2
✓ Branch 0 taken 909 times.
✗ Branch 1 not taken.
909 if(!sourceBitmap)
8008 {
8009 Z_message("Warning: blit(%d) source bitmap contains invalid data or is not initialized.\n", ref);
8010 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
8011 return;
8012 }
8013
8014 909 BITMAP *destBMP=NULL;
8015 //zprint2("RevBlit bitmap index is: %d\n",bitmapIndex);
8016
8017
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
909 switch(bitmapIndex)
8018 {
8019 case -2:
8020 {
8021 int32_t curr_rt = zscriptDrawingRenderTarget->GetCurrentRenderTarget();
8022 //zprint2("current RT is: %d\n", curr_rt);
8023 if ( curr_rt >= 0 && curr_rt < 7 )
8024 destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); //Drawing to the current RenderTarget.
8025 else destBMP = bmp; //screen
8026 break;
8027 }
8028 case -1:
8029 3 destBMP = bmp; //this is framebuf, by default
8030 3 break;
8031 //zscriptDrawingRenderTarget->SetCurrentRenderTarget(bitmapIndex);
8032 //destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex);
8033 //destBMP = framebuf; //Drawing to the screen.
8034 //break;
8035
8036 //1 through 6 are the old system bitmaps (Render Targets)
8037 case 0:
8038 case 1:
8039 case 2:
8040 case 3:
8041 case 4:
8042 case 5:
8043 case 6:
8044 {
8045 //This gets a render target.
8046 //destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); break;
8047
8048 destBMP = zscriptDrawingRenderTarget->GetTargetBitmap(bitmapIndex);
8049 //sdci[18] = bitmapIndex;
8050 break;
8051 }
8052 //Otherwise, we are using a user-created bitmap, so, get that pointer insted.
8053 default:
8054 {
8055 906 destBMP = scb.script_created_bitmaps[usr_bitmap_index].u_bmp;
8056 //sdci[18] = usr_bitmap_index;
8057
1/2
✓ Branch 0 taken 906 times.
✗ Branch 1 not taken.
906 if ( !scb.script_created_bitmaps[usr_bitmap_index].u_bmp )
8058 {
8059 Z_scripterrlog("Target for bitmap->Blit is uninitialised. Aborting.\n");
8060 break;
8061 }
8062 }
8063 //FFCore.get_user_bitmap(bitmapIndex); break;
8064 906 }
8065
8066 #if LOG_BMPBLIT_LEVEL > 0
8067 Z_scripterrlog("bitmap->Blit() is trying to blit to dest bitmap ID: %d\n",bitmapIndex);
8068 #endif
8069
8070
8071
1/2
✓ Branch 0 taken 909 times.
✗ Branch 1 not taken.
909 if (!destBMP)
8072 {
8073 Z_message("Warning: blit(%d) destination bitmap contains invalid data or is not initialized.\n", bitmapIndex);
8074 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
8075 return;
8076 }
8077
8078 //bugfix
8079 //sx = vbound(sx, 0, sourceBitmap->w);
8080 #if LOG_BMPBLIT_LEVEL > 0
8081 Z_scripterrlog("Blit %s is: %d\n", "sx", sx);
8082 Z_scripterrlog("Blit %s is: %d\n", "source->w", sourceBitmap->w);
8083 #endif
8084 //sy = vbound(sy, 0, sourceBitmap->h);
8085 #if LOG_BMPBLIT_LEVEL > 0
8086 Z_scripterrlog("Blit %s is: %d\n", "sy", sy);
8087 Z_scripterrlog("Blit %s is: %d\n", "source->h", sourceBitmap->h);
8088 #endif
8089 //sw = vbound(sw, 0, sourceBitmap->w - sx); //keep the w/h within range as well
8090 #if LOG_BMPBLIT_LEVEL > 0
8091 Z_scripterrlog("Blit %s is: %d\n", "sw", sw);
8092 #endif
8093 //sh = vbound(sh, 0, sourceBitmap->h - sy);
8094 #if LOG_BMPBLIT_LEVEL > 0
8095 Z_scripterrlog("Blit %s is: %d\n", "sh", sh);
8096
8097 Z_scripterrlog("Blit %s is: %d\n", "dx", dx);
8098 Z_scripterrlog("Blit %s is: %d\n", "dy", dy);
8099 Z_scripterrlog("Blit %s is: %d\n", "dh", dh);
8100 Z_scripterrlog("Blit %s is: %d\n", "dw", dw);
8101 Z_scripterrlog("Blit %s is: %d\n", "yoffset", yoffset);
8102 #endif
8103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 909 times.
909 bool stretched = (sw != dw || sh != dh);
8104 //bool stretched = (sourceBitmap->w != destBMP->w || sourceBitmap->h != destBMP->h);
8105 #if LOG_BMPBLIT_LEVEL > 0
8106 Z_scripterrlog("Blit %s is: %s\n", "stretched", stretched ? "true" : "false");
8107 #endif
8108 //BITMAP *sourceBitmap = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex);
8109
8110
8111
8112 909 BITMAP* newDest = sourceBitmap;
8113 909 BITMAP* newSource = destBMP; //Flip them.
8114
8115 909 BITMAP* subBmp = 0;
8116
8117 /* IDR what this was. -Z ( 17th April, 2019 )
8118 if ( bitmapIndex == -1 ) {
8119 blit(bmp, sourceBitmap, sx, sy, 0, 0, dw, dh);
8120 }
8121 */
8122
8123
2/4
✓ Branch 0 taken 909 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 909 times.
909 if(rot != 0 || mode != 0)
8124 {
8125 subBmp = create_bitmap_ex(8,sourceBitmap->w, sourceBitmap->h);//script_drawing_commands.AquireSubBitmap(dw, dh);
8126 clear_bitmap(subBmp);
8127
8128 if(!subBmp)
8129 {
8130 Z_scripterrlog("bitmap->Blit failed to create a sub-bitmap to use for %s. Aborting.\n", "rotation");
8131 return;
8132 }
8133 }
8134
8135
3/4
✓ Branch 0 taken 909 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 906 times.
909 if (sx + sw > destBMP->w || sy + sh > destBMP->h)
8136 {
8137 3 newSource = create_bitmap_ex(8, sw, sh);
8138 3 clear_bitmap(newSource);
8139 3 blit(destBMP, newSource, sx, sy, 0, 0, std::min(destBMP->w-sx, sw), std::min(destBMP->h-sy, sh));
8140 3 sx = 0;
8141 3 sy = 0;
8142 3 }
8143 //dx = dx + xoffset; //don't do this here!
8144 //dy = dy + yoffset; //Nor this. It auto-offsets the bitmap by +56. Hmm. The fix that gleeok made isn't being applied to these functions. -Z ( 17th April, 2019 )
8145
8146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 909 times.
909 if(stretched)
8147 {
8148 if(masked)
8149 { //stretched and masked
8150 if ( rot == 0 )
8151 { //if not rotated
8152 switch(mode)
8153 {
8154 case 1:
8155 //transparent
8156 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8157 draw_trans_sprite(newDest, subBmp, dx, dy);
8158 break;
8159
8160
8161 case 2:
8162 //pivot?
8163 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8164 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8165 //Pivoting requires two more args
8166 break;
8167
8168 case 3:
8169 //pivot + trans
8170 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8171 pivot_sprite_trans(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8172 break;
8173
8174 case 4:
8175 //flip v
8176 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8177 draw_sprite_v_flip(newDest, subBmp, dx, dy);
8178 break;
8179
8180 case 5:
8181 //trans + v flip
8182 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8183 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
8184 break;
8185
8186 case 6:
8187 //pivot + v flip
8188 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8189 pivot_sprite_v_flip(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8190 break;
8191
8192 case 8:
8193 //vlip h
8194 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8195 draw_sprite_h_flip(newDest, subBmp, dx, dy);
8196 break;
8197
8198 case 9:
8199 //trans + h flip
8200 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8201 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
8202 break;
8203
8204 case 10:
8205 //flip H and pivot
8206 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8207 //return error cannot pivot and h flip
8208 break;
8209
8210 case 12:
8211 //vh flip
8212 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8213 draw_sprite_vh_flip(newDest, subBmp, dx, dy);
8214 break;
8215
8216 case 13:
8217 //trans + vh flip
8218 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8219 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
8220 break;
8221
8222 case 14:
8223 //pivot and vh flip
8224 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8225 //return error cannot both pivot and vh flip
8226 break;
8227
8228 case 16:
8229 //lit
8230 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8231 draw_lit_sprite(newDest, subBmp, dx, dy, litcolour);
8232 break;
8233
8234 case 18:
8235 //pivot, lit
8236 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8237 pivot_sprite_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8238 break;
8239
8240 case 20:
8241 //lit + v flip
8242 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8243 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
8244 break;
8245
8246 case 22:
8247 //Pivot, vflip, lit
8248 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8249 pivot_sprite_v_flip_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8250 break;
8251
8252 case 24:
8253 //lit + h flip
8254 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8255 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
8256 break;
8257
8258 case 26:
8259 //pivot + lit + hflip
8260 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
8261 //return error cannot pivot, lit, and flip
8262 break;
8263
8264 case 28:
8265 //lit + vh flip
8266 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8267 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
8268 break;
8269
8270 case 32: //gouraud
8271 //Probably not wort supporting.
8272 //masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8273 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8274 break;
8275
8276 case 0:
8277 //no effect
8278 masked_stretch_blit(newSource, newDest, sx, sy, sw, sh, dx, dy, dw, dh);
8279 break;
8280
8281
8282 default:
8283 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8284
8285
8286 }
8287 } //end if not rotated
8288
8289 if ( rot != 0 ) //if rotated
8290 {
8291 switch(mode)
8292 {
8293 case 1:
8294 //transparent
8295 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8296 rotate_sprite_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8297
8298 break;
8299
8300 case 2:
8301 //pivot?
8302 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8303 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8304 //Pivoting requires two more args
8305 break;
8306
8307 case 3:
8308 //pivot + trans
8309 //return an error, cannot both rotate and pivot
8310 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8311 break;
8312
8313 case 4:
8314 //flip v
8315 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8316 rotate_sprite_v_flip(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8317 break;
8318
8319 case 5:
8320 //trans + v flip
8321 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8322 rotate_sprite_v_flip_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8323 break;
8324
8325 case 6:
8326 //pivot + v flip
8327 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8328 //return an error, cannot both rotate and pivot
8329 break;
8330
8331 case 8:
8332 //flip h
8333 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
8334 //return an error, cannot both rotate and flip H
8335 break;
8336
8337 case 9:
8338 //trans + h flip
8339 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
8340 //return an error, cannot rotate and flip a trans sprite
8341 break;
8342
8343 case 10:
8344 //flip H and pivot
8345 //return error cannot pivot and h flip
8346 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8347 break;
8348
8349 case 12:
8350 //vh flip
8351 //return an error, cannot rotate and VH flip a trans sprite
8352 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
8353 break;
8354
8355 case 13:
8356 //trans + vh flip
8357 //return an error, cannot rotate and VH flip a trans sprite
8358 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
8359 break;
8360
8361 case 14:
8362 //pivot and vh flip
8363 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
8364 //return error cannot both pivot and vh flip
8365 break;
8366
8367 case 16:
8368 //lit
8369 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8370 rotate_sprite_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
8371 break;
8372
8373 case 18:
8374 //pivot, lit
8375 //return an error, cannot both rotate and pivot
8376 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8377 break;
8378
8379 case 20:
8380 //lit + vflip
8381 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8382 rotate_sprite_v_flip_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
8383 break;
8384
8385 case 22:
8386 //Pivot, vflip, lit
8387 //return an error, cannot both rotate and pivot
8388 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
8389 break;
8390
8391 case 24:
8392 //lit + h flip
8393 //return an error, cannot both rotate and H flip
8394 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
8395 break;
8396
8397 case 26:
8398 //pivot + lit + hflip
8399 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
8400 //return error cannot pivot, lit, and flip
8401 break;
8402
8403 case 28:
8404 //lit + vh flip
8405 //return an error, cannot both rotate and VH flip
8406 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8407 break;
8408
8409 case 32: //gouraud
8410 //Probably not wort supporting.
8411 //masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8412 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8413 break;
8414
8415 case 0:
8416 //no effect.
8417 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8418 rotate_sprite(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8419 break;
8420
8421 default:
8422 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8423
8424 }
8425 }
8426 } //end if stretched and masked
8427
8428 else //stretched, not masked
8429 {
8430
8431
8432 if ( rot == 0 ) //if not rotated
8433 {
8434 switch(mode)
8435 {
8436 case 1:
8437 //transparent
8438 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8439 draw_trans_sprite(newDest, subBmp, dx, dy);
8440 break;
8441
8442
8443 case 2:
8444 //pivot?
8445 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8446 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8447 //Pivoting requires two more args
8448 break;
8449
8450 case 3:
8451 //pivot + trans
8452 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8453 pivot_sprite_trans(newDest, subBmp, dx,dy, cx, cy, degrees_to_fixed(rot));
8454 break;
8455
8456 case 4:
8457 //flip v
8458 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8459 draw_sprite_v_flip(newDest, subBmp, dx, dy);
8460 break;
8461
8462 case 5:
8463 //trans + v flip
8464 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8465 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
8466 break;
8467
8468 case 6:
8469 //pivot + v flip
8470 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8471 pivot_sprite_v_flip(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8472 break;
8473
8474 case 8:
8475 //vlip h
8476 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8477 draw_sprite_h_flip(newDest, subBmp, dx, dy);
8478 break;
8479
8480 case 9:
8481 //trans + h flip
8482 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8483 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
8484 break;
8485
8486 case 10:
8487 //flip H and pivot
8488 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8489 //return error cannot pivot and h flip
8490 break;
8491
8492 case 12:
8493 //vh flip
8494 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8495 draw_sprite_vh_flip(newDest, subBmp, dx, dy);
8496 break;
8497
8498 case 13:
8499 //trans + vh flip
8500 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8501 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
8502 break;
8503
8504 case 14:
8505 //pivot and vh flip
8506 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8507 //return error cannot both pivot and vh flip
8508 break;
8509
8510 case 16:
8511 //lit
8512 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8513 draw_lit_sprite(newDest, subBmp, dx, dy, litcolour);
8514 break;
8515
8516 case 18:
8517 //pivot, lit
8518 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8519 pivot_sprite_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8520 break;
8521
8522 case 20:
8523 //lit + v flip
8524 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8525 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
8526 break;
8527
8528 case 22:
8529 //Pivot, vflip, lit
8530 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8531 pivot_sprite_v_flip_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8532 break;
8533
8534 case 24:
8535 //lit + h flip
8536 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8537 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
8538 break;
8539
8540 case 26:
8541 //pivot + lit + hflip
8542 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
8543 //return error cannot pivot, lit, and flip
8544 break;
8545
8546 case 28:
8547 //lit + vh flip
8548 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8549 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
8550 break;
8551
8552 case 32: //gouraud
8553 //Probably not wort supporting.
8554 //stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8555 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8556 break;
8557
8558 case 0:
8559 //no effect
8560 stretch_blit(newSource, newDest, sx, sy, sw, sh, dx, dy, dw, dh);
8561 break;
8562
8563
8564 default:
8565 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8566
8567
8568 }
8569 } //end if not rotated
8570
8571 if ( rot != 0 ) //if rotated
8572 {
8573 switch(mode)
8574 {
8575 case 1:
8576 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
8577 rotate_sprite_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8578
8579 break;
8580
8581 case 2:
8582 //pivot?
8583 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8584 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8585 //Pivoting requires two more args
8586 break;
8587
8588 case 3:
8589 //pivot + trans
8590 //return an error, cannot both rotate and pivot
8591 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8592 break;
8593
8594 case 4:
8595 //flip v
8596 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8597 rotate_sprite_v_flip(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8598 break;
8599
8600 case 5:
8601 //trans + v flip
8602 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8603 rotate_sprite_v_flip_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8604 break;
8605
8606 case 6:
8607 //pivot + v flip
8608 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8609 //return an error, cannot both rotate and pivot
8610 break;
8611
8612 case 8:
8613 //flip h
8614 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
8615 //return an error, cannot both rotate and flip H
8616 break;
8617
8618 case 9:
8619 //trans + h flip
8620 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
8621 //return an error, cannot rotate and flip a trans sprite
8622 break;
8623
8624 case 10:
8625 //flip H and pivot
8626 //return error cannot pivot and h flip
8627 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8628 break;
8629
8630 case 12:
8631 //vh flip
8632 //return an error, cannot rotate and VH flip a trans sprite
8633 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
8634 break;
8635
8636 case 13:
8637 //trans + vh flip
8638 //return an error, cannot rotate and VH flip a trans sprite
8639 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
8640 break;
8641
8642 case 14:
8643 //pivot and vh flip
8644 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
8645 //return error cannot both pivot and vh flip
8646 break;
8647
8648 case 16:
8649 //lit
8650 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
8651 rotate_sprite_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
8652 break;
8653
8654 case 18:
8655 //pivot, lit
8656 //return an error, cannot both rotate and pivot
8657 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8658 break;
8659
8660 case 20:
8661 //lit + vflip
8662 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
8663 rotate_sprite_v_flip_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
8664 break;
8665
8666 case 22:
8667 //Pivot, vflip, lit
8668 //return an error, cannot both rotate and pivot
8669 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
8670 break;
8671
8672 case 24:
8673 //lit + h flip
8674 //return an error, cannot both rotate and H flip
8675 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
8676 break;
8677
8678 case 26:
8679 //pivot + lit + hflip
8680 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
8681 //return error cannot pivot, lit, and flip
8682 break;
8683
8684 case 28:
8685 //lit + vh flip
8686 //return an error, cannot both rotate and VH flip
8687 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8688 break;
8689
8690 case 32: //gouraud
8691 //Probably not wort supporting.
8692 //stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8693 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8694 break;
8695
8696 case 0:
8697 //no effect.
8698 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8699 rotate_sprite(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8700 break;
8701
8702 default:
8703 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8704
8705 }
8706 }
8707
8708 } //end if stretched, but not masked
8709 }
8710 else //not stretched
8711 {
8712
8713
2/2
✓ Branch 0 taken 906 times.
✓ Branch 1 taken 3 times.
909 if(masked) //if masked, but not stretched
8714 {
8715
8716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if ( rot == 0 ) //if not rotated
8717 {
8718
1/22
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 906 times.
906 switch(mode)
8719 {
8720 case 1:
8721 //transparent
8722 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8723 draw_trans_sprite(newDest, subBmp, dx, dy);
8724 break;
8725
8726
8727 case 2:
8728 //pivot?
8729 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8730 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8731 //Pivoting requires two more args
8732 break;
8733
8734 case 3:
8735 //pivot + trans
8736 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8737 pivot_sprite_trans(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8738 break;
8739
8740 case 4:
8741 //flip v
8742 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8743 draw_sprite_v_flip(newDest, subBmp, dx, dy);
8744 break;
8745
8746 case 5:
8747 //trans + v flip
8748 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8749 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
8750 break;
8751
8752 case 6:
8753 //pivot + v flip
8754 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8755 pivot_sprite_v_flip(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8756 break;
8757
8758 case 8:
8759 //vlip h
8760 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8761 draw_sprite_h_flip(newDest, subBmp, dx, dy);
8762 break;
8763
8764 case 9:
8765 //trans + h flip
8766 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8767 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
8768 break;
8769
8770 case 10:
8771 //flip H and pivot
8772 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8773 //return error cannot pivot and h flip
8774 break;
8775
8776 case 12:
8777 //vh flip
8778 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8779 draw_sprite_vh_flip(newDest, subBmp, dx, dy);
8780 break;
8781
8782 case 13:
8783 //trans + vh flip
8784 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8785 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
8786 break;
8787
8788 case 14:
8789 //pivot and vh flip
8790 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8791 //return error cannot both pivot and vh flip
8792 break;
8793
8794 case 16:
8795 //lit
8796 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8797 draw_lit_sprite(newDest, subBmp, dx, dy, litcolour);
8798 break;
8799
8800 case 18:
8801 //pivot, lit
8802 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8803 pivot_sprite_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8804 break;
8805
8806 case 20:
8807 //lit + v flip
8808 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8809 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
8810 break;
8811
8812 case 22:
8813 //Pivot, vflip, lit
8814 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8815 pivot_sprite_v_flip_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8816 break;
8817
8818 case 24:
8819 //lit + h flip
8820 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8821 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
8822 break;
8823
8824 case 26:
8825 //pivot + lit + hflip
8826 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
8827 //return error cannot pivot, lit, and flip
8828 break;
8829
8830 case 28:
8831 //lit + vh flip
8832 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8833 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
8834 break;
8835
8836 case 32: //gouraud
8837 //Probably not wort supporting.
8838 //stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8839 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8840 break;
8841
8842 case 0:
8843 //no effect
8844 906 masked_blit(newSource, newDest, sx, sy, dx, dy, dw, dh);
8845 906 break;
8846
8847
8848 default:
8849 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8850
8851
8852 }
8853 906 } //end if not rotated
8854
8855
1/2
✓ Branch 0 taken 906 times.
✗ Branch 1 not taken.
906 if ( rot != 0 ) //if rotated
8856 {
8857 switch(mode)
8858 {
8859 case 1:
8860 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); //transparent
8861 rotate_sprite_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8862
8863 break;
8864
8865 case 2:
8866 //pivot?
8867 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8868 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8869 //Pivoting requires two more args
8870 break;
8871
8872 case 3:
8873 //pivot + trans
8874 //return an error, cannot both rotate and pivot
8875 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8876 break;
8877
8878 case 4:
8879 //flip v
8880 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8881 rotate_sprite_v_flip(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8882 break;
8883
8884 case 5:
8885 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); //trans + v flip
8886 rotate_sprite_v_flip_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8887 break;
8888
8889 case 6:
8890 //pivot + v flip
8891 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8892 //return an error, cannot both rotate and pivot
8893 break;
8894
8895 case 8:
8896 //flip h
8897 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
8898 //return an error, cannot both rotate and flip H
8899 break;
8900
8901 case 9:
8902 //trans + h flip
8903 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
8904 //return an error, cannot rotate and flip a trans sprite
8905 break;
8906
8907 case 10:
8908 //flip H and pivot
8909 //return error cannot pivot and h flip
8910 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8911 break;
8912
8913 case 12:
8914 //vh flip
8915 //return an error, cannot rotate and VH flip a trans sprite
8916 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
8917 break;
8918
8919 case 13:
8920 //trans + vh flip
8921 //return an error, cannot rotate and VH flip a trans sprite
8922 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
8923 break;
8924
8925 case 14:
8926 //pivot and vh flip
8927 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
8928 //return error cannot both pivot and vh flip
8929 break;
8930
8931 case 16:
8932 //lit
8933 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8934 rotate_sprite_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
8935 break;
8936
8937 case 18:
8938 //pivot, lit
8939 //return an error, cannot both rotate and pivot
8940 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8941 break;
8942
8943 case 20:
8944 //lit + vflip
8945 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8946 rotate_sprite_v_flip_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
8947 break;
8948
8949 case 22:
8950 //Pivot, vflip, lit
8951 //return an error, cannot both rotate and pivot
8952 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
8953 break;
8954
8955 case 24:
8956 //lit + h flip
8957 //return an error, cannot both rotate and H flip
8958 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
8959 break;
8960
8961 case 26:
8962 //pivot + lit + hflip
8963 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
8964 //return error cannot pivot, lit, and flip
8965 break;
8966
8967 case 28:
8968 //lit + vh flip
8969 //return an error, cannot both rotate and VH flip
8970 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8971 break;
8972
8973 case 32: //gouraud
8974 //Probably not wort supporting.
8975 //stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8976 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8977 break;
8978
8979 case 0:
8980 //no effect.
8981 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8982 rotate_sprite(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8983 break;
8984
8985 default:
8986 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8987
8988 }
8989 } //end rtated, masked
8990 906 } //end if masked
8991
8992 else //not masked, and not stretched; just blit
8993 {
8994
8995
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if ( rot == 0 ) //if not rotated
8996 {
8997
1/22
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 3 times.
3 switch(mode)
8998 {
8999 case 1:
9000 //transparent
9001 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9002 draw_trans_sprite(newDest, subBmp, dx, dy);
9003 break;
9004
9005
9006 case 2:
9007 //pivot?
9008 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9009 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9010 //Pivoting requires two more args
9011 break;
9012
9013 case 3:
9014 //pivot + trans
9015 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9016 pivot_sprite_trans(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9017 break;
9018
9019 case 4:
9020 //flip v
9021 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9022 draw_sprite_v_flip(newDest, subBmp, dx, dy);
9023 break;
9024
9025 case 5:
9026 //trans + v flip
9027 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9028 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
9029 break;
9030
9031 case 6:
9032 //pivot + v flip
9033 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9034 pivot_sprite_v_flip(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9035 break;
9036
9037 case 8:
9038 //vlip h
9039 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9040 draw_sprite_h_flip(newDest, subBmp, dx, dy);
9041 break;
9042
9043 case 9:
9044 //trans + h flip
9045 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9046 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
9047 break;
9048
9049 case 10:
9050 //flip H and pivot
9051 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
9052 //return error cannot pivot and h flip
9053 break;
9054
9055 case 12:
9056 //vh flip
9057 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9058 draw_sprite_vh_flip(newDest, subBmp, dx, dy);
9059 break;
9060
9061 case 13:
9062 //trans + vh flip
9063 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9064 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
9065 break;
9066
9067 case 14:
9068 //pivot and vh flip
9069 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
9070 //return error cannot both pivot and vh flip
9071 break;
9072
9073 case 16:
9074 //lit
9075 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9076 draw_lit_sprite(newDest, subBmp, dx, dy, litcolour);
9077 break;
9078
9079 case 18:
9080 //pivot, lit
9081 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9082 pivot_sprite_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
9083 break;
9084
9085 case 20:
9086 //lit + v flip
9087 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9088 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
9089 break;
9090
9091 case 22:
9092 //Pivot, vflip, lit
9093 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9094 pivot_sprite_v_flip_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
9095 break;
9096
9097 case 24:
9098 //lit + h flip
9099 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9100 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
9101 break;
9102
9103 case 26:
9104 //pivot + lit + hflip
9105 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
9106 //return error cannot pivot, lit, and flip
9107 break;
9108
9109 case 28:
9110 //lit + vh flip
9111 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9112 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
9113 break;
9114
9115 case 32: //gouraud
9116 //Probably not wort supporting.
9117 //blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9118 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
9119 break;
9120
9121 case 0:
9122 //no effect
9123 3 blit(newSource, newDest, sx, sy, dx, dy, dw, dh);
9124 3 break;
9125
9126
9127 default:
9128 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
9129
9130
9131 }
9132 3 } //end if not rotated
9133
9134
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if ( rot != 0 ) //if rotated
9135 {
9136 switch(mode)
9137 {
9138 case 1:
9139 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);//transparent
9140 rotate_sprite_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
9141
9142 break;
9143
9144 case 2:
9145 //pivot?
9146 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9147 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9148 //Pivoting requires two more args
9149 break;
9150
9151 case 3:
9152 //pivot + trans
9153 //return an error, cannot both rotate and pivot
9154 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
9155 break;
9156
9157 case 4:
9158 //flip v
9159 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9160 rotate_sprite_v_flip(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
9161 break;
9162
9163 case 5:
9164 //trans + v flip
9165 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9166 rotate_sprite_v_flip_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
9167 break;
9168
9169 case 6:
9170 //pivot + v flip
9171 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
9172 //return an error, cannot both rotate and pivot
9173 break;
9174
9175 case 8:
9176 //flip h
9177 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
9178 //return an error, cannot both rotate and flip H
9179 break;
9180
9181 case 9:
9182 //trans + h flip
9183 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
9184 //return an error, cannot rotate and flip a trans sprite
9185 break;
9186
9187 case 10:
9188 //flip H and pivot
9189 //return error cannot pivot and h flip
9190 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
9191 break;
9192
9193 case 12:
9194 //vh flip
9195 //return an error, cannot rotate and VH flip a trans sprite
9196 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
9197 break;
9198
9199 case 13:
9200 //trans + vh flip
9201 //return an error, cannot rotate and VH flip a trans sprite
9202 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
9203 break;
9204
9205 case 14:
9206 //pivot and vh flip
9207 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
9208 //return error cannot both pivot and vh flip
9209 break;
9210
9211 case 16:
9212 //lit
9213 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9214 rotate_sprite_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
9215 break;
9216
9217 case 18:
9218 //pivot, lit
9219 //return an error, cannot both rotate and pivot
9220 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
9221 break;
9222
9223 case 20:
9224 //lit + vflip
9225 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9226 rotate_sprite_v_flip_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
9227 break;
9228
9229 case 22:
9230 //Pivot, vflip, lit
9231 //return an error, cannot both rotate and pivot
9232 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
9233 break;
9234
9235 case 24:
9236 //lit + h flip
9237 //return an error, cannot both rotate and H flip
9238 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
9239 break;
9240
9241 case 26:
9242 //pivot + lit + hflip
9243 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
9244 //return error cannot pivot, lit, and flip
9245 break;
9246
9247 case 28:
9248 //lit + vh flip
9249 //return an error, cannot both rotate and VH flip
9250 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
9251 break;
9252
9253 case 32: //gouraud
9254 //Probably not wort supporting.
9255 //blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9256 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
9257 break;
9258
9259 case 0:
9260 //no effect.
9261 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9262 rotate_sprite(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
9263 break;
9264
9265 default:
9266 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
9267
9268 }
9269 } //end if rotated
9270 } //end if not masked
9271 } //end if not stretched
9272
9273 //cleanup
9274
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 909 times.
909 if(subBmp)
9275 {
9276 //script_drawing_commands.ReleaseSubBitmap(subBmp); //purge the temporary bitmap.
9277 destroy_bitmap(subBmp);
9278 }
9279
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 906 times.
909 if(newSource != destBMP)
9280 {
9281 3 destroy_bitmap(newSource);
9282 3 }
9283 909 }
9284
9285
9286 void bmp_do_drawquad3dr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
9287 {
9288
9289 //sdci[1]=layer
9290 //sdci[2]=pos[12]
9291 //sdci[3]=uv[8]
9292 //sdci[4]=color[4]
9293 //sdci[5]=size[2]
9294 //sdci[6]=flip
9295 //sdci[7]=tile/combo
9296 //sdci[8]=polytype
9297 //sdci[9] = other bitmap as texture
9298 //sdci[17] Bitmap Pointer
9299 if ( sdci[17] <= 0 )
9300 {
9301 Z_scripterrlog("bitmap->Quad3D() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
9302 return;
9303 }
9304 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
9305 if ( refbmp == NULL ) return;
9306
9307 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
9308
9309 if(!v_ptr)
9310 {
9311 al_trace("Quad3d: Vector pointer is null! Internal error. \n");
9312 return;
9313 }
9314
9315 std::vector<int32_t> &v = *v_ptr;
9316
9317 if(v.empty())
9318 return;
9319
9320 int32_t* pos = &v[0];
9321 int32_t* uv = &v[12];
9322 int32_t* col = &v[20];
9323 int32_t* size = &v[24];
9324
9325 int32_t w = size[0]; //magic numerical constants... yuck.
9326 int32_t h = size[1];
9327 int32_t flip = (sdci[6]/10000)&3;
9328 int32_t tile = sdci[7]/10000;
9329 int32_t polytype = sdci[8]/10000;
9330 int32_t quad_render_source = sdci[9]-10;
9331 Z_scripterrlog("Quad3D texture is %d\n", quad_render_source);
9332
9333 polytype = vbound(polytype, 0, 14);
9334
9335 int32_t tex_width = w*16;
9336 int32_t tex_height = h*16;
9337
9338 bool mustDestroyBmp = false;
9339 BITMAP *tex=NULL;
9340
9341
9342 bool tex_is_bitmap = ( sdci[9] != 0 );
9343 //Z_scripterrlog("sdci[9] is %d\n", quad_render_source);
9344 //Z_scripterrlog("sdci[17] is %d\n", sdci[17]-10);
9345 BITMAP *bmptexture;
9346
9347 if ( tex_is_bitmap ) bmptexture = FFCore.GetScriptBitmap(quad_render_source);
9348
9349 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
9350
9351
9352 if ( !tex_is_bitmap )
9353 {
9354 tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
9355
9356 if(!tex)
9357 {
9358 mustDestroyBmp = true;
9359 tex = create_bitmap_ex(8, tex_width, tex_height);
9360 clear_bitmap(tex);
9361 }
9362 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
9363 {
9364 Z_message("Quad3d() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
9365 return; //non power of two error
9366 }
9367 if(tile > 0) // TILE
9368 {
9369 TileHelper::OverTile(tex, tile, 0, 0, w, h, col[0], flip);
9370 }
9371 else // COMBO
9372 {
9373 const newcombo & c = combobuf[ vbound(abs(tile), 0, 0xffff) ];
9374 const int32_t tiletodraw = combo_tile(c, 0, 0);
9375 flip = flip ^ c.flip;
9376
9377 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, col[0], flip);
9378 }
9379
9380 V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] };
9381 V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] };
9382 V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] };
9383 V3D_f V4 = { static_cast<float>(pos[9]+xoffset), static_cast<float>(pos[10]+yoffset), static_cast<float>(pos[11]), static_cast<float>(uv[6]), static_cast<float>(uv[7]), col[3] };
9384
9385 quad3d_f(refbmp, polytype, tex, &V1, &V2, &V3, &V4);
9386 if(mustDestroyBmp)
9387 destroy_bitmap(tex);
9388 }
9389 else
9390 {
9391
9392 if ( !bmptexture )
9393 {
9394 Z_scripterrlog("Bitmap pointer used as a texture in %s is uninitialised.\n Defaulting to using a tile as a texture.\n", "bitmap->Quad3D()");
9395 tex_is_bitmap = 0;
9396 return;
9397 }
9398 if ( !isPowerOfTwo(bmptexture->h) ) Z_scripterrlog("HEIGHT of Bitmap ( pointer %d ) provided as a render source for bitmap->Quad3D is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source);
9399 if ( !isPowerOfTwo(bmptexture->w) ) Z_scripterrlog("WIDTH of Bitmap ( pointer %d ) provided as a render source for bitmap->Quad3D is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source);
9400 if ( !isPowerOfTwo(h) ) Z_scripterrlog("WIDTH ARG (%d) provided as a render source for bitmap->Quad3D is not a POWER OF TWO.\nTextels may render improperly!\n", h);
9401 if ( !isPowerOfTwo(w) ) Z_scripterrlog("HEIGHT ARG (%d) provided as a render source for bitmap->Quad3D is not a POWER OF TWO.\nTextels may render improperly!\n", w);
9402
9403 V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] };
9404 V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] };
9405 V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] };
9406 V3D_f V4 = { static_cast<float>(pos[9]+xoffset), static_cast<float>(pos[10]+yoffset), static_cast<float>(pos[11]), static_cast<float>(uv[6]), static_cast<float>(uv[7]), col[3] };
9407
9408 BITMAP *foo = create_bitmap_ex(8, 256, 176);
9409
9410 //quad3d_f(refbmp, polytype, foo, &V1, &V2, &V3, &V4);
9411 quad3d_f(refbmp, polytype, bmptexture, &V1, &V2, &V3, &V4);
9412 destroy_bitmap(foo);
9413
9414 }
9415
9416
9417
9418 }
9419
9420
9421
9422 void bmp_do_drawtriangle3dr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
9423 {
9424 //sdci[1]=layer
9425 //sdci[2]=pos[9]
9426 //sdci[3]=uv[6]
9427 //sdci[4]=color[3]
9428 //sdci[5]=size[2]
9429 //sdci[6]=flip
9430 //sdci[7]=tile/combo
9431 //sdci[8]=polytype
9432 //sdci[9] bitmap as texture
9433 //sdci[17] Bitmap Pointer
9434 if ( sdci[17] <= 0 )
9435 {
9436 Z_scripterrlog("bitmap->Triangle3D() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
9437 return;
9438 }
9439 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
9440 if ( refbmp == NULL ) return;
9441
9442 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
9443
9444 if(!v_ptr)
9445 {
9446 al_trace("bitmap->Triangle3d: Vector pointer is null! Internal error. \n");
9447 return;
9448 }
9449
9450 std::vector<int32_t> &v = *v_ptr;
9451
9452 if(v.empty())
9453 return;
9454
9455 int32_t* pos = &v[0];
9456 int32_t* uv = &v[9];
9457 int32_t* col = &v[15];
9458 int32_t* size = &v[18];
9459
9460 int32_t w = size[0]; //magic numerical constants... yuck.
9461 int32_t h = size[1];
9462 int32_t flip = (sdci[6]/10000)&3;
9463 int32_t tile = sdci[7]/10000;
9464 int32_t polytype = sdci[8]/10000;
9465 int32_t quad_render_source = sdci[9]-10;
9466 polytype = vbound(polytype, 0, 14);
9467
9468 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
9469 {
9470 Z_message("bitmap->Triangle3d() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
9471 return; //non power of two error
9472 }
9473
9474 int32_t tex_width = w*16;
9475 int32_t tex_height = h*16;
9476
9477 bool mustDestroyBmp = false;
9478 BITMAP *tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
9479
9480 if(!tex)
9481 {
9482 mustDestroyBmp = true;
9483 tex = create_bitmap_ex(8, tex_width, tex_height);
9484 clear_bitmap(tex);
9485 }
9486
9487 bool tex_is_bitmap = ( sdci[9] != 0 );
9488 BITMAP *bmptexture=NULL;
9489 if ( tex_is_bitmap )
9490 {
9491 bmptexture = FFCore.GetScriptBitmap(quad_render_source);
9492 if ( !bmptexture )
9493 {
9494 Z_scripterrlog("Bitmap pointer used as a texture in %s is uninitialised.\n Defaulting to using a tile as a texture.\n", "bitmap->Triangle3()");
9495 tex_is_bitmap = 0;
9496 }
9497 }
9498
9499 if ( !tex_is_bitmap )
9500 {
9501 if(tile > 0) // TILE
9502 {
9503 TileHelper::OverTile(tex, tile, 0, 0, w, h, col[0], flip);
9504 }
9505 else // COMBO
9506 {
9507 const newcombo & c = combobuf[ vbound(abs(tile), 0, 0xffff) ];
9508 const int32_t tiletodraw = combo_tile(c, 0, 0);
9509 flip = flip ^ c.flip;
9510
9511 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, col[0], flip);
9512 }
9513
9514 V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] };
9515 V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] };
9516 V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] };
9517
9518 triangle3d_f(refbmp, polytype, tex, &V1, &V2, &V3);
9519 }
9520 else
9521 {
9522 if ( !isPowerOfTwo(bmptexture->h) ) Z_scripterrlog("HEIGHT of Bitmap ( pointer %d ) provided as a render source for bitmap->Triangle3D is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source);
9523 if ( !isPowerOfTwo(bmptexture->w) ) Z_scripterrlog("WIDTH of Bitmap ( pointer %d ) provided as a render source for bitmap->Triangle3D is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source);
9524 if ( !isPowerOfTwo(w) ) Z_scripterrlog("WIDTH ARG (%d) provided as a render source for bitmap->Triangle3D is not a POWER OF TWO.\nTextels may render improperly!\n", w);
9525 if ( !isPowerOfTwo(h) ) Z_scripterrlog("HEIGHT ARG (%d) provided as a render source for bitmap->Triangle3D is not a POWER OF TWO.\nTextels may render improperly!\n", h);
9526
9527 V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] };
9528 V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] };
9529 V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] };
9530
9531 triangle3d_f(refbmp, polytype, bmptexture, &V1, &V2, &V3);
9532
9533
9534 }
9535 if(mustDestroyBmp)
9536 destroy_bitmap(tex);
9537
9538 }
9539
9540
9541 bool is_layer_transparent(const mapscr& m, int32_t layer)
9542 {
9543 layer = vbound(layer, 0, 5);
9544 return m.layeropacity[layer] == 128;
9545 }
9546
9547 4328553 mapscr *getmapscreen(int32_t map_index, int32_t screen_index, int32_t layer) //returns NULL for invalid or non-existent layer
9548 {
9549 mapscr *base_screen;
9550 4328553 int32_t index = map_index*MAPSCRS+screen_index;
9551
9552
2/4
✓ Branch 0 taken 4328553 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4328553 times.
4328553 if((uint32_t)layer > 6 || (uint32_t)index >= TheMaps.size())
9553 return NULL;
9554
9555
2/2
✓ Branch 0 taken 3543647 times.
✓ Branch 1 taken 784906 times.
4328553 if(layer != 0)
9556 {
9557 784906 layer = layer - 1;
9558
9559 784906 base_screen=&(TheMaps[index]);
9560
9561
2/2
✓ Branch 0 taken 748179 times.
✓ Branch 1 taken 36727 times.
784906 if(base_screen->layermap[layer]==0)
9562 36727 return NULL;
9563
9564 748179 index=(base_screen->layermap[layer]-1)*MAPSCRS+base_screen->layerscreen[layer];
9565
9566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 748179 times.
748179 if((uint32_t)index >= TheMaps.size()) // Might as well make sure
9567 return NULL;
9568 748179 }
9569
9570 4291826 return &(TheMaps[index]);
9571 4328553 }
9572
9573 3210 void draw_mapscr(BITMAP *b, const mapscr& m, int32_t x, int32_t y, bool transparent)
9574 {
9575
2/2
✓ Branch 0 taken 564960 times.
✓ Branch 1 taken 3210 times.
568170 for(int32_t i(0); i < 176; ++i)
9576 {
9577 564960 const int32_t x2 = ((i&15)<<4) + x;
9578 564960 const int32_t y2 = (i&0xF0) + y;
9579
9580 //const newcombo & c = combobuf[ m.data[i] ];
9581 /*
9582 newcombo c = combobuf[m.data[i]];
9583 int32_t csets[4];
9584 int32_t cofs = c.csets&15;
9585
9586 if(cofs&8)
9587 cofs |= ~int32_t(0xF);
9588
9589 for(int32_t i=0; i<4; ++i)
9590 csets[i] = c.csets&(16<<i) ? cset + cofs : cset;
9591
9592
9593 const int32_t tile = combo_tile(c, x2, y2);
9594 */
9595
9596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 564960 times.
564960 if(transparent)
9597 {
9598 //void overcomboblocktranslucent(BITMAP *dest, int32_t x, int32_t y, int32_t cmbdat, int32_t cset, int32_t w, int32_t h, int32_t opacity)
9599 overcomboblocktranslucent(b, x2, y2, m.data[i], m.cset[i], 1, 1, 128);
9600 //overtiletranslucent16(b, tile, x2, y2, m.cset[i], c.flip, 128);
9601 }
9602 else
9603 {
9604 //overcomboblock(BITMAP *dest, int32_t x, int32_t y, int32_t cmbdat, int32_t cset, int32_t w, int32_t h)
9605 564960 overcomboblock(b, x2, y2, m.data[i], m.cset[i], 1, 1);
9606 //overtile16(b, tile, x2, y2, m.cset[i], c.flip);
9607 }
9608 564960 }
9609 3210 }
9610
9611 void draw_map_solidity(BITMAP *b, const mapscr& m, int32_t x, int32_t y)
9612 {
9613 BITMAP* square = create_bitmap_ex(8,16,16);
9614
9615 for(int32_t i(0); i < 176; ++i)
9616 {
9617 const int32_t x2 = ((i&15)<<4) + x;
9618 const int32_t y2 = (i&0xF0) + y;
9619 //Blit the palette index of the solidity value.
9620 //int32_t col = (combobuf[m.data[i]].walk&15);
9621 //if ( col != 0 )
9622 //{
9623 // Z_scripterrlog("Position %d has a solidity value of %d.\n", i, col);
9624 //
9625 //}
9626 clear_to_color(square,(combobuf[m.data[i]].walk&15));
9627 if (get_bit(quest_rules, qr_BROKEN_DRAWSCREEN_FUNCTIONS)) blit(square, b, 0, 0, x2, y2, square->w, square->h);
9628 else masked_blit(square, b, 0, 0, x2, y2, square->w, square->h);
9629 }
9630 destroy_bitmap(square);
9631 }
9632
9633 void do_bmpdrawscreen_solidmaskr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
9634 {
9635 //sdci[1]=layer
9636 //sdci[2]=map
9637 //sdci[3]=screen
9638 //sdci[4]=x
9639 //sdci[5]=y
9640 //sdci[6]=rotation
9641 //sdci[17] Bitmap Pointer
9642
9643 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
9644 if ( refbmp == NULL ) return;
9645
9646 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
9647
9648 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
9649 int32_t scrn = sdci[3]/10000;
9650 int32_t x = sdci[4]/10000;
9651 int32_t y = sdci[5]/10000;
9652 int32_t x1 = x + xoffset;
9653 int32_t y1 = y + yoffset;
9654 int32_t rotation = sdci[6]/10000;
9655
9656 const uint32_t index = (uint32_t)(map * MAPSCRS + scrn);
9657
9658 if(index >= TheMaps.size())
9659 {
9660 al_trace("DrawScreen: invalid map or screen index. \n");
9661 return;
9662 }
9663
9664 const mapscr & m = TheMaps[index];
9665
9666
9667 BITMAP* b = FFCore.GetScriptBitmap(sdci[17]-10);
9668 if ( refbmp == NULL ) return;
9669
9670 if(rotation != 0)
9671 b = script_drawing_commands.AquireSubBitmap(256, 176);
9672
9673 //draw layer 0
9674 draw_map_solidity(b, m, x1, y1);
9675 if (get_bit(quest_rules, qr_BROKEN_DRAWSCREEN_FUNCTIONS))
9676 {
9677 for(int32_t i(0); i < 6; ++i)
9678 {
9679 if(m.layermap[i] == 0) continue;
9680
9681 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
9682
9683 if(layer_screen_index >= TheMaps.size())
9684 continue;
9685
9686 //draw valid layers
9687 draw_map_solidity(b, TheMaps[ layer_screen_index ], x1, y1);
9688 }
9689 }
9690
9691 if(rotation != 0) // rotate
9692 {
9693 rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation));
9694 script_drawing_commands.ReleaseSubBitmap(b);
9695 }
9696 }
9697
9698 void draw_map_solid(BITMAP *b, const mapscr& m, int32_t x, int32_t y)
9699 {
9700 BITMAP* square = create_bitmap_ex(8,16,16);
9701 BITMAP* subsquare = create_bitmap_ex(8,16,16);
9702 clear_to_color(subsquare,1);
9703
9704 for(int32_t i(0); i < 176; ++i)
9705 {
9706 const int32_t x2 = ((i&15)<<4) + x;
9707 const int32_t y2 = (i&0xF0) + y;
9708 //Blit the palette index of the solidity value.
9709 //int32_t col = (combobuf[m.data[i]].walk&15);
9710 //if ( col != 0 )
9711 //{
9712 // Z_scripterrlog("Position %d has a solidity value of %d.\n", i, col);
9713 //
9714 //}
9715 clear_bitmap(square);
9716 int32_t sol = (combobuf[m.data[i]].walk);
9717 //al_trace("Solidity is: %d.\n", sol);
9718 if ( sol & 1 )
9719 {
9720 blit(subsquare, square, 0, 0, 0, 0, 8, 8);
9721 }
9722 if ( sol & 2 )
9723 {
9724 blit(subsquare, square, 0, 0, 0, 8, 8, 8);
9725 }
9726 if ( sol & 4 )
9727 {
9728 blit(subsquare, square, 0, 0, 8, 0, 8, 8);
9729 }
9730 if ( sol &8 ) {
9731 blit(subsquare, square, 0, 0, 8, 8, 8, 8);
9732 }
9733
9734 if (get_bit(quest_rules, qr_BROKEN_DRAWSCREEN_FUNCTIONS)) blit(square, b, 0, 0, x2, y2, square->w, square->h);
9735 else masked_blit(square, b, 0, 0, x2, y2, square->w, square->h);
9736 }
9737 destroy_bitmap(square);
9738 destroy_bitmap(subsquare);
9739 }
9740
9741 void do_bmpdrawscreen_solidr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
9742 {
9743 //sdci[1]=layer
9744 //sdci[2]=map
9745 //sdci[3]=screen
9746 //sdci[4]=x
9747 //sdci[5]=y
9748 //sdci[6]=rotation
9749 //sdci[17] Bitmap Pointer
9750
9751 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
9752 if ( refbmp == NULL ) return;
9753
9754 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
9755
9756 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
9757 int32_t scrn = sdci[3]/10000;
9758 int32_t x = sdci[4]/10000;
9759 int32_t y = sdci[5]/10000;
9760 int32_t x1 = x + xoffset;
9761 int32_t y1 = y + yoffset;
9762 int32_t rotation = sdci[6]/10000;
9763
9764 const uint32_t index = (uint32_t)(map * MAPSCRS + scrn);
9765
9766 if(index >= TheMaps.size())
9767 {
9768 al_trace("DrawScreen: invalid map or screen index. \n");
9769 return;
9770 }
9771
9772 const mapscr & m = TheMaps[index];
9773
9774
9775 BITMAP* b = FFCore.GetScriptBitmap(sdci[17]-10);
9776 if ( refbmp == NULL ) return;
9777
9778 if(rotation != 0)
9779 b = script_drawing_commands.AquireSubBitmap(256, 176);
9780
9781 //draw layer 0
9782 draw_map_solid(b, m, x1, y1);
9783
9784 for(int32_t i(0); i < 6; ++i) //This one doesn't need the QR; it works just fine.
9785 {
9786 if(m.layermap[i] == 0) continue;
9787
9788 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
9789
9790 if(layer_screen_index >= TheMaps.size())
9791 continue;
9792
9793 //draw valid layers
9794 draw_map_solid(b, TheMaps[ layer_screen_index ], x1, y1);
9795 }
9796
9797 if(rotation != 0) // rotate
9798 {
9799 rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation));
9800 script_drawing_commands.ReleaseSubBitmap(b);
9801 }
9802 }
9803
9804 1024 void draw_map_cflag(BITMAP *b, const mapscr& m, int32_t x, int32_t y)
9805 {
9806 1024 BITMAP* square = create_bitmap_ex(8,16,16);
9807
9808
2/2
✓ Branch 0 taken 180224 times.
✓ Branch 1 taken 1024 times.
181248 for(int32_t i(0); i < 176; ++i)
9809 {
9810 180224 const int32_t x2 = ((i&15)<<4) + x;
9811 180224 const int32_t y2 = (i&0xF0) + y;
9812 //Blit the palette index of the solidity value.
9813 180224 clear_to_color(square,m.sflag[i]);
9814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180224 times.
180224 if (get_bit(quest_rules, qr_BROKEN_DRAWSCREEN_FUNCTIONS)) blit(square, b, 0, 0, x2, y2, square->w, square->h);
9815 180224 else masked_blit(square, b, 0, 0, x2, y2, square->w, square->h);
9816 180224 }
9817 1024 destroy_bitmap(square);
9818 1024 }
9819
9820 1024 void do_bmpdrawscreen_cflagr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
9821 {
9822 //sdci[1]=layer
9823 //sdci[2]=map
9824 //sdci[3]=screen
9825 //sdci[4]=x
9826 //sdci[5]=y
9827 //sdci[6]=rotation
9828 //sdci[17] Bitmap Pointer
9829
9830 1024 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
9831
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if ( refbmp == NULL ) return;
9832
9833
2/4
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1024 times.
1024 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
9834
9835 1024 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
9836 1024 int32_t scrn = sdci[3]/10000;
9837 1024 int32_t x = sdci[4]/10000;
9838 1024 int32_t y = sdci[5]/10000;
9839 1024 int32_t x1 = x + xoffset;
9840 1024 int32_t y1 = y + yoffset;
9841 1024 int32_t rotation = sdci[6]/10000;
9842
9843 1024 const uint32_t index = (uint32_t)(map * MAPSCRS + scrn);
9844
9845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
1024 if(index >= TheMaps.size())
9846 {
9847 al_trace("DrawScreen: invalid map or screen index. \n");
9848 return;
9849 }
9850
9851 1024 const mapscr & m = TheMaps[index];
9852
9853
9854 1024 BITMAP* b = FFCore.GetScriptBitmap(sdci[17]-10);
9855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
1024 if ( refbmp == NULL ) return;
9856
9857
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(rotation != 0)
9858 b = script_drawing_commands.AquireSubBitmap(256, 176);
9859
9860 //draw layer 0
9861 1024 draw_map_cflag(b, m, x1, y1);
9862
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if (get_bit(quest_rules, qr_BROKEN_DRAWSCREEN_FUNCTIONS))
9863 {
9864 for(int32_t i(0); i < 6; ++i)
9865 {
9866 if(m.layermap[i] == 0) continue;
9867
9868 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
9869
9870 if(layer_screen_index >= TheMaps.size())
9871 continue;
9872
9873 //draw valid layers
9874 draw_map_cflag(b, TheMaps[ layer_screen_index ], x1, y1);
9875 }
9876 }
9877
9878
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(rotation != 0) // rotate
9879 {
9880 rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation));
9881 script_drawing_commands.ReleaseSubBitmap(b);
9882 }
9883 1024 }
9884
9885
9886 void draw_map_combotype(BITMAP *b, const mapscr& m, int32_t x, int32_t y)
9887 {
9888 BITMAP* square = create_bitmap_ex(8,16,16);
9889
9890 for(int32_t i(0); i < 176; ++i)
9891 {
9892 const int32_t x2 = ((i&15)<<4) + x;
9893 const int32_t y2 = (i&0xF0) + y;
9894 //Blit the palette index of the solidity value.
9895 clear_to_color(square,(combobuf[m.data[i]].type));
9896 if (get_bit(quest_rules, qr_BROKEN_DRAWSCREEN_FUNCTIONS)) blit(square, b, 0, 0, x2, y2, square->w, square->h);
9897 else masked_blit(square, b, 0, 0, x2, y2, square->w, square->h);
9898 }
9899 destroy_bitmap(square);
9900 }
9901
9902 void do_bmpdrawscreen_ctyper(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
9903 {
9904 //sdci[1]=layer
9905 //sdci[2]=map
9906 //sdci[3]=screen
9907 //sdci[4]=x
9908 //sdci[5]=y
9909 //sdci[6]=rotation
9910 //sdci[17] Bitmap Pointer
9911
9912 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
9913 if ( refbmp == NULL ) return;
9914
9915 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
9916
9917 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
9918 int32_t scrn = sdci[3]/10000;
9919 int32_t x = sdci[4]/10000;
9920 int32_t y = sdci[5]/10000;
9921 int32_t x1 = x + xoffset;
9922 int32_t y1 = y + yoffset;
9923 int32_t rotation = sdci[6]/10000;
9924
9925 const uint32_t index = (uint32_t)(map * MAPSCRS + scrn);
9926
9927 if(index >= TheMaps.size())
9928 {
9929 al_trace("DrawScreen: invalid map or screen index. \n");
9930 return;
9931 }
9932
9933 const mapscr & m = TheMaps[index];
9934
9935
9936 BITMAP* b = FFCore.GetScriptBitmap(sdci[17]-10);
9937 if ( refbmp == NULL ) return;
9938
9939 if(rotation != 0)
9940 b = script_drawing_commands.AquireSubBitmap(256, 176);
9941
9942 //draw layer 0
9943 draw_map_combotype(b, m, x1, y1);
9944
9945 if (get_bit(quest_rules, qr_BROKEN_DRAWSCREEN_FUNCTIONS))
9946 {
9947 for(int32_t i(0); i < 6; ++i)
9948 {
9949 if(m.layermap[i] == 0) continue;
9950
9951 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
9952
9953 if(layer_screen_index >= TheMaps.size())
9954 continue;
9955
9956 //draw valid layers
9957 draw_map_combotype(b, TheMaps[ layer_screen_index ], x1, y1);
9958 }
9959 }
9960
9961 if(rotation != 0) // rotate
9962 {
9963 rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation));
9964 script_drawing_commands.ReleaseSubBitmap(b);
9965 }
9966 }
9967
9968
9969 void draw_map_comboiflag(BITMAP *b, const mapscr& m, int32_t x, int32_t y)
9970 {
9971 BITMAP* square = create_bitmap_ex(8,16,16);
9972
9973 for(int32_t i(0); i < 176; ++i)
9974 {
9975 const int32_t x2 = ((i&15)<<4) + x;
9976 const int32_t y2 = (i&0xF0) + y;
9977 //Blit the palette index of the solidity value.
9978 clear_to_color(square,(combobuf[m.data[i]].flag));
9979 if (get_bit(quest_rules, qr_BROKEN_DRAWSCREEN_FUNCTIONS)) blit(square, b, 0, 0, x2, y2, square->w, square->h);
9980 else masked_blit(square, b, 0, 0, x2, y2, square->w, square->h);
9981 }
9982 destroy_bitmap(square);
9983 }
9984
9985 void do_bmpdrawscreen_ciflagr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
9986 {
9987 //sdci[1]=layer
9988 //sdci[2]=map
9989 //sdci[3]=screen
9990 //sdci[4]=x
9991 //sdci[5]=y
9992 //sdci[6]=rotation
9993 //sdci[17] Bitmap Pointer
9994
9995 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
9996 if ( refbmp == NULL ) return;
9997
9998 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
9999
10000 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
10001 int32_t scrn = sdci[3]/10000;
10002 int32_t x = sdci[4]/10000;
10003 int32_t y = sdci[5]/10000;
10004 int32_t x1 = x + xoffset;
10005 int32_t y1 = y + yoffset;
10006 int32_t rotation = sdci[6]/10000;
10007
10008 const uint32_t index = (uint32_t)(map * MAPSCRS + scrn);
10009
10010 if(index >= TheMaps.size())
10011 {
10012 al_trace("DrawScreen: invalid map or screen index. \n");
10013 return;
10014 }
10015
10016 const mapscr & m = TheMaps[index];
10017
10018
10019 BITMAP* b = FFCore.GetScriptBitmap(sdci[17]-10);
10020 if ( refbmp == NULL ) return;
10021
10022 if(rotation != 0)
10023 b = script_drawing_commands.AquireSubBitmap(256, 176);
10024
10025 //draw layer 0
10026 draw_map_comboiflag(b, m, x1, y1);
10027
10028 if (get_bit(quest_rules, qr_BROKEN_DRAWSCREEN_FUNCTIONS))
10029 {
10030 for(int32_t i(0); i < 6; ++i)
10031 {
10032 if(m.layermap[i] == 0) continue;
10033
10034 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
10035
10036 if(layer_screen_index >= TheMaps.size())
10037 continue;
10038
10039 //draw valid layers
10040 draw_map_comboiflag(b, TheMaps[ layer_screen_index ], x1, y1);
10041 }
10042 }
10043
10044 if(rotation != 0) // rotate
10045 {
10046 rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation));
10047 script_drawing_commands.ReleaseSubBitmap(b);
10048 }
10049 }
10050
10051 4327380 void do_drawlayerr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
10052 {
10053 //sdci[1]=layer
10054 //sdci[2]=map
10055 //sdci[3]=screen
10056 //sdci[4]=layer
10057 //sdci[5]=x
10058 //sdci[6]=y
10059 //sdci[7]=rotation
10060 //sdci[8]=opacity
10061
10062 4327380 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
10063 4327380 int32_t scrn = sdci[3]/10000;
10064 4327380 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
10065 4327380 int32_t x = sdci[5]/10000;
10066 4327380 int32_t y = sdci[6]/10000;
10067 4327380 int32_t x1 = x + xoffset;
10068 4327380 int32_t y1 = y + yoffset;
10069 4327380 int32_t rotation = sdci[7]/10000;
10070 4327380 int32_t opacity = sdci[8]/10000;
10071
10072 4327380 const uint32_t index = (uint32_t)(map * MAPSCRS + scrn);
10073 4327380 const mapscr* m = getmapscreen(map, scrn, sourceLayer);
10074
10075
2/2
✓ Branch 0 taken 4290659 times.
✓ Branch 1 taken 36721 times.
4327380 if(!m) //no need to log it.
10076 36721 return;
10077
10078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4290659 times.
4290659 if(index >= TheMaps.size())
10079 {
10080 al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size());
10081 return;
10082 }
10083
10084 4290659 const mapscr & l = *m;
10085
10086 4290659 BITMAP* b = bmp;
10087
10088
1/2
✓ Branch 0 taken 4290659 times.
✗ Branch 1 not taken.
4290659 if(rotation != 0)
10089 b = script_drawing_commands.AquireSubBitmap(256, 176);
10090
10091
10092 4290659 const int32_t maxX = isOffScreen ? 512 : 256;
10093
2/2
✓ Branch 0 taken 4280939 times.
✓ Branch 1 taken 9720 times.
4290659 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
10094 4290659 bool transparent = opacity <= 128;
10095
10096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4290659 times.
4290659 if(rotation != 0) // rotate
10097 {
10098 draw_mapscr(b, l, x1, y1, transparent);
10099
10100 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
10101 script_drawing_commands.ReleaseSubBitmap(b);
10102 }
10103 else
10104 {
10105
2/2
✓ Branch 0 taken 755155984 times.
✓ Branch 1 taken 4290659 times.
759446643 for(int32_t i(0); i < 176; ++i)
10106 {
10107 755155984 const int32_t x2 = ((i&15)<<4) + x1;
10108 755155984 const int32_t y2 = (i&0xF0) + y1;
10109
10110
7/8
✓ Branch 0 taken 664698870 times.
✓ Branch 1 taken 90457114 times.
✓ Branch 2 taken 664698870 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 610281598 times.
✓ Branch 5 taken 54417272 times.
✓ Branch 6 taken 9155742 times.
✓ Branch 7 taken 601125856 times.
755155984 if(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY) //in clipping rect
10111 {
10112 601125856 const newcombo & c = combobuf[ l.data[i] ];
10113 601125856 const int32_t tile = combo_tile(c, x2, y2);
10114
10115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 601125856 times.
601125856 if(opacity < 128)
10116 {
10117 overcomboblocktranslucent(b, x2, y2, l.data[i], l.cset[i], 1, 1, 128);
10118
10119
10120 //overtiletranslucent16(b, tile, x2, y2, l.cset[i], c.flip, opacity);
10121 }
10122 else
10123 {
10124 601125856 overcomboblock(b, x2, y2, l.data[i], l.cset[i], 1, 1);
10125 //overtile16(b, tile, x2, y2, l.cset[i], c.flip);
10126 }
10127 //putcombo( b, xx, yy, l.data[i], l.cset[i] );
10128 601125856 }
10129 755155984 }
10130 }
10131
10132 //putscr
10133 4327380 }
10134
10135
10136
10137 void do_drawscreenr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
10138 {
10139 //sdci[1]=layer
10140 //sdci[2]=map
10141 //sdci[3]=screen
10142 //sdci[4]=x
10143 //sdci[5]=y
10144 //sdci[6]=rotation
10145
10146 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
10147 int32_t scrn = sdci[3]/10000;
10148 int32_t x = sdci[4]/10000;
10149 int32_t y = sdci[5]/10000;
10150 int32_t x1 = x + xoffset;
10151 int32_t y1 = y + yoffset;
10152 int32_t rotation = sdci[6]/10000;
10153
10154 const uint32_t index = (uint32_t)(map * MAPSCRS + scrn);
10155
10156 if(index >= TheMaps.size())
10157 {
10158 al_trace("DrawScreen: invalid map or screen index. \n");
10159 return;
10160 }
10161
10162 const mapscr & m = TheMaps[index];
10163
10164
10165 BITMAP* b = bmp;
10166
10167 if(rotation != 0)
10168 b = script_drawing_commands.AquireSubBitmap(256, 176);
10169
10170 //draw layer 0
10171 draw_mapscr(b, m, x1, y1, false);
10172
10173 for(int32_t i(0); i < 6; ++i)
10174 {
10175 if(m.layermap[i] == 0) continue;
10176
10177 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
10178
10179 if(layer_screen_index >= TheMaps.size())
10180 continue;
10181
10182 bool trans = m.layeropacity[i] == 128;
10183
10184 //draw valid layers
10185 draw_mapscr(b, TheMaps[ layer_screen_index ], x1, y1, trans);
10186 }
10187
10188 if(rotation != 0) // rotate
10189 {
10190 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
10191 script_drawing_commands.ReleaseSubBitmap(b);
10192 }
10193 }
10194
10195
10196 1173 void do_bmpdrawlayerr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
10197 {
10198 //sdci[1]=layer
10199 //sdci[2]=map
10200 //sdci[3]=screen
10201 //sdci[4]=layer
10202 //sdci[5]=x
10203 //sdci[6]=y
10204 //sdci[7]=rotation
10205 //[8] noclip
10206 //sdci[9]=opacity
10207 //sdci[17] Bitmap Pointer
10208
10209 1173 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
10210
1/2
✓ Branch 0 taken 1173 times.
✗ Branch 1 not taken.
1173 if ( refbmp == NULL ) return;
10211
10212 1173 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
10213 1173 int32_t scrn = sdci[3]/10000;
10214 1173 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
10215 1173 int32_t x = sdci[5]/10000;
10216 1173 int32_t y = sdci[6]/10000;
10217 1173 int32_t rotation = sdci[7]/10000;
10218
10219 1173 byte noclip = 0;//(sdci[8]!=0);
10220 1173 int32_t opacity = sdci[8]/10000;
10221 //zprint2("Running bmp->DrawLayer(%d, %d, %d, %d, %d, %d, %d, %d)\n", sdci[1]/10000, map, scrn, sourceLayer, x, y, rotation, opacity);
10222 1173 const uint32_t index = (uint32_t)(map * MAPSCRS + scrn);
10223 1173 const mapscr* m = getmapscreen(map, scrn, sourceLayer);
10224
10225
2/2
✓ Branch 0 taken 1167 times.
✓ Branch 1 taken 6 times.
1173 if(!m) //no need to log it.
10226 6 return;
10227
10228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1167 times.
1167 if(index >= TheMaps.size())
10229 {
10230 Z_scripterrlog("DrawLayer: invalid map index \"%i\". Map count is %d.\n", index, TheMaps.size());
10231 return;
10232 }
10233
10234 1167 const mapscr & l = *m;
10235
10236 1167 BITMAP* b = FFCore.GetScriptBitmap(sdci[17]-10);
10237
1/2
✓ Branch 0 taken 1167 times.
✗ Branch 1 not taken.
1167 if ( refbmp == NULL ) return;
10238
2/4
✓ Branch 0 taken 1167 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1167 times.
✗ Branch 3 not taken.
1167 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
10239
1/2
✓ Branch 0 taken 1167 times.
✗ Branch 1 not taken.
1167 if(rotation != 0)
10240 b = script_drawing_commands.AquireSubBitmap(256, 176);
10241
10242
10243 1167 const int32_t maxX = isOffScreen ? 512 : 256;
10244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1167 times.
1167 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
10245 1167 bool transparent = opacity <= 128;
10246
10247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1167 times.
1167 if(rotation != 0) // rotate
10248 {
10249 draw_mapscr(b, l, x, y, transparent);
10250
10251 rotate_sprite(refbmp, b, x, y, degrees_to_fixed(rotation));
10252 script_drawing_commands.ReleaseSubBitmap(b);
10253 }
10254 else
10255 {
10256
2/2
✓ Branch 0 taken 205392 times.
✓ Branch 1 taken 1167 times.
206559 for(int32_t i(0); i < 176; ++i)
10257 {
10258 205392 const int32_t x2 = ((i&15)<<4) + x;
10259 205392 const int32_t y2 = (i&0xF0) + y;
10260
10261 //if(noclip&&(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect
10262 {
10263 205392 const newcombo & c = combobuf[ l.data[i] ];
10264 205392 const int32_t tile = combo_tile(c, x2, y2);
10265
10266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205392 times.
205392 if(opacity < 128)
10267 overtiletranslucent16(refbmp, tile, x2, y2, l.cset[i], c.flip, opacity);
10268 else
10269 205392 overtile16(refbmp, tile, x2, y2, l.cset[i], c.flip);
10270
10271 //putcombo( b, xx, yy, l.data[i], l.cset[i] );
10272 }
10273 205392 }
10274 }
10275
10276 //putscr
10277 1173 }
10278
10279
10280
10281 1092 void do_bmpdrawscreenr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
10282 {
10283 //sdci[1]=layer
10284 //sdci[2]=map
10285 //sdci[3]=screen
10286 //sdci[4]=x
10287 //sdci[5]=y
10288 //sdci[6]=rotation
10289 //sdci[17] Bitmap Pointer
10290
10291 1092 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
10292
1/2
✓ Branch 0 taken 1092 times.
✗ Branch 1 not taken.
1092 if ( refbmp == NULL ) return;
10293
10294
2/4
✓ Branch 0 taken 1092 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1092 times.
1092 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
10295
10296 1092 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
10297 1092 int32_t scrn = sdci[3]/10000;
10298 1092 int32_t x = sdci[4]/10000;
10299 1092 int32_t y = sdci[5]/10000;
10300 1092 int32_t x1 = x + xoffset;
10301 1092 int32_t y1 = y + yoffset;
10302 1092 int32_t rotation = sdci[6]/10000;
10303
10304 1092 const uint32_t index = (uint32_t)(map * MAPSCRS + scrn);
10305
10306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1092 times.
1092 if(index >= TheMaps.size())
10307 {
10308 al_trace("DrawScreen: invalid map or screen index. \n");
10309 return;
10310 }
10311
10312 1092 const mapscr & m = TheMaps[index];
10313
10314
10315 1092 BITMAP* b = FFCore.GetScriptBitmap(sdci[17]-10);
10316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1092 times.
1092 if ( refbmp == NULL ) return;
10317
10318
1/2
✓ Branch 0 taken 1092 times.
✗ Branch 1 not taken.
1092 if(rotation != 0)
10319 b = script_drawing_commands.AquireSubBitmap(256, 176);
10320
10321 //draw layer 0
10322 1092 draw_mapscr(b, m, x1, y1, false);
10323
10324
2/2
✓ Branch 0 taken 1092 times.
✓ Branch 1 taken 6552 times.
7644 for(int32_t i(0); i < 6; ++i)
10325 {
10326
2/2
✓ Branch 0 taken 2118 times.
✓ Branch 1 taken 4434 times.
6552 if(m.layermap[i] == 0) continue;
10327
10328 2118 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
10329
10330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2118 times.
2118 if(layer_screen_index >= TheMaps.size())
10331 continue;
10332
10333 2118 bool trans = m.layeropacity[i] == 128;
10334
10335 //draw valid layers
10336 2118 draw_mapscr(b, TheMaps[ layer_screen_index ], x1, y1, trans);
10337 2118 }
10338
10339
1/2
✓ Branch 0 taken 1092 times.
✗ Branch 1 not taken.
1092 if(rotation != 0) // rotate
10340 {
10341 rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation));
10342 script_drawing_commands.ReleaseSubBitmap(b);
10343 }
10344 1092 }
10345
10346 void do_bmpdrawlayersolidmaskr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
10347 {
10348 //sdci[1]=layer
10349 //sdci[2]=map
10350 //sdci[3]=screen
10351 //sdci[4]=layer
10352 //sdci[5]=x
10353 //sdci[6]=y
10354 //sdci[7]=rotation
10355 //sdci[8]=bool noclip
10356 //sdci[9] == opacity
10357
10358 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
10359 int32_t scrn = sdci[3]/10000;
10360 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
10361 int32_t x = sdci[5]/10000;
10362 int32_t y = sdci[6]/10000;
10363 int32_t x1 = x + xoffset;
10364 int32_t y1 = y + yoffset;
10365 int32_t rotation = sdci[7]/10000;
10366 byte noclip = (sdci[8]!=0);
10367 int32_t opacity = sdci[9]/10000;
10368
10369 const uint32_t index = (uint32_t)(map * MAPSCRS + scrn);
10370 const mapscr* m = getmapscreen(map, scrn, sourceLayer);
10371
10372 if(!m) //no need to log it.
10373 return;
10374
10375 if(index >= TheMaps.size())
10376 {
10377 al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size());
10378 return;
10379 }
10380
10381 const mapscr & l = *m;
10382
10383 BITMAP* b = bmp;
10384
10385 if(rotation != 0)
10386 b = script_drawing_commands.AquireSubBitmap(256, 176);
10387
10388
10389 const int32_t maxX = isOffScreen ? 512 : 256;
10390 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
10391 bool transparent = opacity <= 128;
10392
10393 if(rotation != 0) // rotate
10394 {
10395 draw_map_solid(b, l, x1, y1);
10396
10397 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
10398 script_drawing_commands.ReleaseSubBitmap(b);
10399 }
10400 else
10401 {
10402 BITMAP* square = create_bitmap_ex(8,16,16);
10403 BITMAP* subsquare = create_bitmap_ex(8,16,16);
10404 clear_to_color(subsquare,1);
10405 for(int32_t i(0); i < 176; ++i)
10406 {
10407 const int32_t x2 = ((i&15)<<4) + x1;
10408 const int32_t y2 = (i&0xF0) + y1;
10409
10410 if(noclip&&(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect
10411 {
10412 int32_t sol = (combobuf[l.data[i]].walk);
10413
10414 if ( sol & 1 )
10415 {
10416 blit(subsquare, square, 0, 0, 0, 0, 8, 8);
10417 }
10418 if ( sol & 2 )
10419 {
10420 blit(subsquare, square, 0, 0, 0, 8, 8, 8);
10421 }
10422 if ( sol & 4 )
10423 {
10424 blit(subsquare, square, 0, 0, 8, 0, 8, 8);
10425 }
10426 if ( sol &8 ) {
10427 blit(subsquare, square, 0, 0, 8, 8, 8, 8);
10428 }
10429
10430 blit(square, b, 0, 0, x2, y2, square->w, square->h);
10431 }
10432 }
10433 destroy_bitmap(square);
10434 destroy_bitmap(subsquare);
10435 }
10436
10437 //putscr
10438 }
10439
10440 void do_bmpdrawlayersolidityr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
10441 {
10442 //sdci[1]=layer
10443 //sdci[2]=map
10444 //sdci[3]=screen
10445 //sdci[4]=layer
10446 //sdci[5]=x
10447 //sdci[6]=y
10448 //sdci[7]=rotation
10449 //[8] noclip
10450 //sdci[9]=opacity
10451
10452
10453 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
10454 int32_t scrn = sdci[3]/10000;
10455 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
10456 int32_t x = sdci[5]/10000;
10457 int32_t y = sdci[6]/10000;
10458 int32_t x1 = x + xoffset;
10459 int32_t y1 = y + yoffset;
10460 int32_t rotation = sdci[7]/10000;
10461 byte noclip = (sdci[8]!=0);
10462 int32_t opacity = sdci[9]/10000;
10463
10464 const uint32_t index = (uint32_t)(map * MAPSCRS + scrn);
10465 const mapscr* m = getmapscreen(map, scrn, sourceLayer);
10466
10467 if(!m) //no need to log it.
10468 return;
10469
10470 if(index >= TheMaps.size())
10471 {
10472 al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size());
10473 return;
10474 }
10475
10476 const mapscr & l = *m;
10477
10478 BITMAP* b = bmp;
10479
10480 if(rotation != 0)
10481 b = script_drawing_commands.AquireSubBitmap(256, 176);
10482
10483
10484 const int32_t maxX = isOffScreen ? 512 : 256;
10485 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
10486 bool transparent = opacity <= 128;
10487
10488 if(rotation != 0) // rotate
10489 {
10490 draw_map_solidity(b, l, x1, y1);
10491
10492 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
10493 script_drawing_commands.ReleaseSubBitmap(b);
10494 }
10495 else
10496 {
10497 BITMAP* square = create_bitmap_ex(8,16,16);
10498 for(int32_t i(0); i < 176; ++i)
10499 {
10500 const int32_t x2 = ((i&15)<<4) + x1;
10501 const int32_t y2 = (i&0xF0) + y1;
10502
10503 if(noclip && (x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect
10504 {
10505 clear_to_color(square,(combobuf[l.data[i]].walk&15));
10506 blit(square, b, 0, 0, x2, y2, square->w, square->h);
10507 }
10508 }
10509 destroy_bitmap(square);
10510 }
10511
10512 //putscr
10513 }
10514
10515 void do_bmpdrawlayercflagr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
10516 {
10517 //sdci[1]=layer
10518 //sdci[2]=map
10519 //sdci[3]=screen
10520 //sdci[4]=layer
10521 //sdci[5]=x
10522 //sdci[6]=y
10523 //sdci[7]=rotation
10524 //[8] noclip
10525 //sdci[9]=opacity
10526
10527
10528 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
10529 int32_t scrn = sdci[3]/10000;
10530 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
10531 int32_t x = sdci[5]/10000;
10532 int32_t y = sdci[6]/10000;
10533 int32_t x1 = x + xoffset;
10534 int32_t y1 = y + yoffset;
10535 int32_t rotation = sdci[7]/10000;
10536
10537 byte noclip = (sdci[8]!=0);
10538 int32_t opacity = sdci[9]/10000;
10539
10540 const uint32_t index = (uint32_t)(map * MAPSCRS + scrn);
10541 const mapscr* m = getmapscreen(map, scrn, sourceLayer);
10542
10543 if(!m) //no need to log it.
10544 return;
10545
10546 if(index >= TheMaps.size())
10547 {
10548 al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size());
10549 return;
10550 }
10551
10552 const mapscr & l = *m;
10553
10554 BITMAP* b = bmp;
10555
10556 if(rotation != 0)
10557 b = script_drawing_commands.AquireSubBitmap(256, 176);
10558
10559
10560 const int32_t maxX = isOffScreen ? 512 : 256;
10561 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
10562 bool transparent = opacity <= 128;
10563
10564 if(rotation != 0) // rotate
10565 {
10566 draw_map_cflag(b, l, x1, y1);
10567
10568 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
10569 script_drawing_commands.ReleaseSubBitmap(b);
10570 }
10571 else
10572 {
10573 BITMAP* square = create_bitmap_ex(8,16,16);
10574 for(int32_t i(0); i < 176; ++i)
10575 {
10576 const int32_t x2 = ((i&15)<<4) + x1;
10577 const int32_t y2 = (i&0xF0) + y1;
10578
10579 if(noclip&&(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect
10580 {
10581 clear_to_color(square,l.sflag[i]);
10582 blit(square, b, 0, 0, x2, y2, square->w, square->h);
10583 }
10584 }
10585 destroy_bitmap(square);
10586 }
10587
10588 //putscr
10589 }
10590
10591 void do_bmpdrawlayerctyper(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
10592 {
10593 //sdci[1]=layer
10594 //sdci[2]=map
10595 //sdci[3]=screen
10596 //sdci[4]=layer
10597 //sdci[5]=x
10598 //sdci[6]=y
10599 //sdci[7]=rotation
10600 //[8] noclip
10601 //sdci[9]=opacity
10602
10603 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
10604 int32_t scrn = sdci[3]/10000;
10605 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
10606 int32_t x = sdci[5]/10000;
10607 int32_t y = sdci[6]/10000;
10608 int32_t x1 = x + xoffset;
10609 int32_t y1 = y + yoffset;
10610 int32_t rotation = sdci[7]/10000;
10611
10612 byte noclip = (sdci[8]!=0);
10613 int32_t opacity = sdci[9]/10000;
10614 const uint32_t index = (uint32_t)(map * MAPSCRS + scrn);
10615 const mapscr* m = getmapscreen(map, scrn, sourceLayer);
10616
10617 if(!m) //no need to log it.
10618 return;
10619
10620 if(index >= TheMaps.size())
10621 {
10622 al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size());
10623 return;
10624 }
10625
10626 const mapscr & l = *m;
10627
10628 BITMAP* b = bmp;
10629
10630 if(rotation != 0)
10631 b = script_drawing_commands.AquireSubBitmap(256, 176);
10632
10633
10634 const int32_t maxX = isOffScreen ? 512 : 256;
10635 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
10636 bool transparent = opacity <= 128;
10637
10638 if(rotation != 0) // rotate
10639 {
10640 draw_map_combotype(b, l, x1, y1);
10641
10642 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
10643 script_drawing_commands.ReleaseSubBitmap(b);
10644 }
10645 else
10646 {
10647 BITMAP* square = create_bitmap_ex(8,16,16);
10648 for(int32_t i(0); i < 176; ++i)
10649 {
10650 const int32_t x2 = ((i&15)<<4) + x1;
10651 const int32_t y2 = (i&0xF0) + y1;
10652
10653 if(noclip&&(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect
10654 {
10655 clear_to_color(square,(combobuf[l.data[i]].type));
10656 blit(square, b, 0, 0, x2, y2, square->w, square->h);
10657 }
10658 }
10659 destroy_bitmap(square);
10660 }
10661
10662 //putscr
10663 }
10664
10665 void do_bmpdrawlayerciflagr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
10666 {
10667 //sdci[1]=layer
10668 //sdci[2]=map
10669 //sdci[3]=screen
10670 //sdci[4]=layer
10671 //sdci[5]=x
10672 //sdci[6]=y
10673 //sdci[7]=rotation
10674 //[8] noclip
10675 //sdci[9]=opacity
10676
10677 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
10678 int32_t scrn = sdci[3]/10000;
10679 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
10680 int32_t x = sdci[5]/10000;
10681 int32_t y = sdci[6]/10000;
10682 int32_t x1 = x + xoffset;
10683 int32_t y1 = y + yoffset;
10684 int32_t rotation = sdci[7]/10000;
10685 byte noclip = (sdci[8]!=0);
10686 int32_t opacity = sdci[9]/10000;
10687
10688 const uint32_t index = (uint32_t)(map * MAPSCRS + scrn);
10689 const mapscr* m = getmapscreen(map, scrn, sourceLayer);
10690
10691 if(!m) //no need to log it.
10692 return;
10693
10694 if(index >= TheMaps.size())
10695 {
10696 al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size());
10697 return;
10698 }
10699
10700 const mapscr & l = *m;
10701
10702 BITMAP* b = bmp;
10703
10704 if(rotation != 0)
10705 b = script_drawing_commands.AquireSubBitmap(256, 176);
10706
10707
10708 const int32_t maxX = isOffScreen ? 512 : 256;
10709 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
10710 bool transparent = opacity <= 128;
10711
10712 if(rotation != 0) // rotate
10713 {
10714 draw_map_comboiflag(b, l, x1, y1);
10715
10716 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
10717 script_drawing_commands.ReleaseSubBitmap(b);
10718 }
10719 else
10720 {
10721 BITMAP* square = create_bitmap_ex(8,16,16);
10722 for(int32_t i(0); i < 176; ++i)
10723 {
10724 const int32_t x2 = ((i&15)<<4) + x1;
10725 const int32_t y2 = (i&0xF0) + y1;
10726
10727 if(noclip&&(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect
10728 {
10729 clear_to_color(square,(combobuf[l.data[i]].flag));
10730 blit(square, b, 0, 0, x2, y2, square->w, square->h);
10731 }
10732 }
10733 destroy_bitmap(square);
10734 }
10735
10736 //putscr
10737 }
10738
10739
10740
10741 /////////////////////////////////////////////////////////
10742 // do primitives
10743 ////////////////////////////////////////////////////////
10744
10745 44650310 void do_primitives(BITMAP *targetBitmap, int32_t type, mapscr* theScreen, int32_t xoff, int32_t yoff)
10746 {
10747 44650310 color_map = &trans_table2;
10748
10749 //was this next variable ever used? -- DN
10750 //bool drawsubscr=false;
10751
10752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44650310 times.
44650310 if(type > 7)
10753 return;
10754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44650310 times.
44650310 if(theScreen->hidescriptlayers & (1<<type))
10755 return; //Script draws hidden for this layer
10756 //--script_drawing_commands[][] reference--
10757 //[][0]: type
10758 //[][1-16]: defined by type
10759 //[][17]: unused
10760 //[][18]: rendertarget
10761 //[][19]: unused
10762
10763 // Trying to match the old behavior exactly...
10764
2/2
✓ Branch 0 taken 27995069 times.
✓ Branch 1 taken 16655241 times.
44650310 const bool brokenOffset= ( (get_bit(extra_rules, er_BITMAPOFFSET)!=0) || (get_bit(quest_rules,qr_BITMAPOFFSETFIX)!=0) );
10765
10766 44650310 bool isTargetOffScreenBmp = false;
10767 44650310 const int32_t type_mul_10000 = type * 10000;
10768 44650310 const int32_t numDrawCommandsToProcess = script_drawing_commands.Count();
10769 44650310 FFCore.numscriptdraws = numDrawCommandsToProcess;
10770 44650310 int32_t xoffset=xoff, yoffset=yoff;
10771
2/2
✓ Branch 0 taken 169180927 times.
✓ Branch 1 taken 44650310 times.
213831237 for(int32_t i(0); i < numDrawCommandsToProcess; ++i)
10772 {
10773
2/2
✓ Branch 0 taken 55817487 times.
✓ Branch 1 taken 113363440 times.
169180927 if(!brokenOffset)
10774 {
10775 113363440 xoffset = 0;
10776 113363440 yoffset = 0;
10777 113363440 }
10778 169180927 int32_t *sdci = &script_drawing_commands[i][0];
10779
10780
2/2
✓ Branch 0 taken 147950683 times.
✓ Branch 1 taken 21230244 times.
169180927 if(sdci[1] != type_mul_10000)
10781 147950683 continue;
10782 // get the correct render target, if set.
10783 21230244 BITMAP *bmp = zscriptDrawingRenderTarget->GetTargetBitmap(sdci[18]);
10784
10785
2/2
✓ Branch 0 taken 6015375 times.
✓ Branch 1 taken 15214869 times.
21230244 if(!bmp)
10786 {
10787 // draw to screen with subscreen offset
10788
2/2
✓ Branch 0 taken 6900511 times.
✓ Branch 1 taken 8314358 times.
15214869 if(!brokenOffset)
10789 {
10790 8314358 xoffset = xoff;
10791 8314358 yoffset = yoff;
10792 8314358 }
10793 15214869 bmp = targetBitmap;
10794 15214869 }
10795 else
10796 {
10797 //not drawing to screen, so no subscreen offset
10798
2/2
✓ Branch 0 taken 5932008 times.
✓ Branch 1 taken 83367 times.
6015375 if(brokenOffset)
10799 {
10800 83367 xoffset = 0;
10801 83367 yoffset = 0;
10802 83367 }
10803 6015375 isTargetOffScreenBmp = true;
10804 }
10805
10806
36/82
✗ Branch 0 not taken.
✓ Branch 1 taken 1700780 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 738524 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1850 times.
✓ Branch 6 taken 29242 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 261359 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 761909 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 1074739 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 2787748 times.
✓ Branch 18 taken 7495889 times.
✓ Branch 19 taken 12044 times.
✓ Branch 20 taken 36046 times.
✓ Branch 21 taken 386173 times.
✓ Branch 22 taken 153213 times.
✓ Branch 23 taken 9266 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 777927 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 4327380 times.
✗ Branch 31 not taken.
✓ Branch 32 taken 7818 times.
✗ Branch 33 not taken.
✓ Branch 34 taken 1480 times.
✗ Branch 35 not taken.
✓ Branch 36 taken 502 times.
✓ Branch 37 taken 144 times.
✗ Branch 38 not taken.
✓ Branch 39 taken 80910 times.
✓ Branch 40 taken 59428 times.
✗ Branch 41 not taken.
✓ Branch 42 taken 824 times.
✗ Branch 43 not taken.
✓ Branch 44 taken 167316 times.
✓ Branch 45 taken 784 times.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✓ Branch 49 taken 45504 times.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✓ Branch 56 taken 1173 times.
✓ Branch 57 taken 1092 times.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✓ Branch 60 taken 1024 times.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✓ Branch 63 taken 236166 times.
✗ Branch 64 not taken.
✓ Branch 65 taken 909 times.
✗ Branch 66 not taken.
✗ Branch 67 not taken.
✓ Branch 68 taken 26369 times.
✓ Branch 69 taken 2790 times.
✓ Branch 70 taken 34653 times.
✗ Branch 71 not taken.
✗ Branch 72 not taken.
✗ Branch 73 not taken.
✗ Branch 74 not taken.
✗ Branch 75 not taken.
✗ Branch 76 not taken.
✗ Branch 77 not taken.
✓ Branch 78 taken 6363 times.
✗ Branch 79 not taken.
✓ Branch 80 taken 906 times.
✗ Branch 81 not taken.
21230244 switch(sdci[0])
10807 {
10808 case RECTR:
10809 {
10810 1700780 do_rectr(bmp, sdci, xoffset, yoffset);
10811 }
10812 1700780 break;
10813 case FRAMER:
10814 {
10815 do_framer(bmp, sdci, xoffset, yoffset);
10816 }
10817 break;
10818
10819
10820 case CIRCLER:
10821 {
10822 738524 do_circler(bmp, sdci, xoffset, yoffset);
10823 }
10824 738524 break;
10825
10826 case ARCR:
10827 {
10828 do_arcr(bmp, sdci, xoffset, yoffset);
10829 }
10830 break;
10831
10832 case ELLIPSER:
10833 {
10834 1850 do_ellipser(bmp, sdci, xoffset, yoffset);
10835 }
10836 1850 break;
10837
10838 case LINER:
10839 {
10840 29242 do_liner(bmp, sdci, xoffset, yoffset);
10841 }
10842 29242 break;
10843
10844 case SPLINER:
10845 {
10846 do_spliner(bmp, sdci, xoffset, yoffset);
10847 }
10848 break;
10849
10850 case PUTPIXELR:
10851 {
10852 261359 do_putpixelr(bmp, sdci, xoffset, yoffset);
10853 }
10854 261359 break;
10855 case PIXELARRAYR:
10856 {
10857 //Z_scripterrlog("Reached case PIXELARRAYR\n");
10858 do_putpixelsr(bmp, i, sdci, xoffset, yoffset);
10859 }
10860 break;
10861
10862 case TILEARRAYR:
10863 {
10864 //Z_scripterrlog("Reached case PIXELARRAYR\n");
10865 do_fasttilesr(bmp, i, sdci, xoffset, yoffset);
10866 }
10867 break;
10868
10869 case LINESARRAY:
10870 {
10871 //Z_scripterrlog("Reached case PIXELARRAYR\n");
10872 do_linesr(bmp, i, sdci, xoffset, yoffset);
10873 }
10874 break;
10875
10876 case COMBOARRAYR:
10877 {
10878 //Z_scripterrlog("Reached case PIXELARRAYR\n");
10879 do_fastcombosr(bmp, i, sdci, xoffset, yoffset);
10880 }
10881 break;
10882
10883
10884
10885 case DRAWTILER:
10886 {
10887 761909 do_drawtiler(bmp, sdci, xoffset, yoffset);
10888 }
10889 761909 break;
10890
10891 case DRAWTILECLOAKEDR:
10892 {
10893 do_drawtilecloakedr(bmp, sdci, xoffset, yoffset);
10894 }
10895 break;
10896
10897 case DRAWCOMBOR:
10898 {
10899 1074739 do_drawcombor(bmp, sdci, xoffset, yoffset);
10900 }
10901 1074739 break;
10902
10903 case DRAWCOMBOCLOAKEDR:
10904 {
10905 do_drawcombocloakedr(bmp, sdci, xoffset, yoffset);
10906 }
10907 break;
10908
10909 case FASTTILER:
10910 {
10911 2787748 do_fasttiler(bmp, sdci, xoffset, yoffset);
10912 }
10913 2787748 break;
10914
10915 case FASTCOMBOR:
10916 {
10917 7495889 do_fastcombor(bmp, sdci, xoffset, yoffset);
10918 }
10919 7495889 break;
10920
10921 case DRAWCHARR:
10922 {
10923 12044 do_drawcharr(bmp, sdci, xoffset, yoffset);
10924 }
10925 12044 break;
10926
10927 case DRAWINTR:
10928 {
10929 36046 do_drawintr(bmp, sdci, xoffset, yoffset);
10930 }
10931 36046 break;
10932
10933 case DRAWSTRINGR:
10934 {
10935 386173 do_drawstringr(bmp, i, sdci, xoffset, yoffset);
10936 }
10937 386173 break;
10938
10939 case DRAWSTRINGR2:
10940 {
10941 153213 do_drawstringr2(bmp, i, sdci, xoffset, yoffset);
10942 }
10943 153213 break;
10944
10945 case QUADR:
10946 {
10947 9266 do_drawquadr(bmp, sdci, xoffset, yoffset);
10948 }
10949 9266 break;
10950
10951 case QUAD3DR:
10952 {
10953 do_drawquad3dr(bmp, i, sdci, xoffset, yoffset);
10954 }
10955 break;
10956
10957 case TRIANGLER:
10958 {
10959 do_drawtriangler(bmp, sdci, xoffset, yoffset);
10960 }
10961 break;
10962
10963 case TRIANGLE3DR:
10964 {
10965 do_drawtriangle3dr(bmp, i, sdci, xoffset, yoffset);
10966 }
10967 break;
10968
10969 case POLYGONR:
10970 {
10971 do_polygonr(bmp, i, sdci, xoffset, yoffset);
10972 }
10973 break;
10974
10975
10976 case BITMAPR:
10977 {
10978 777927 do_drawbitmapr(bmp, sdci, xoffset, yoffset);
10979 }
10980 777927 break;
10981
10982 case BITMAPEXR:
10983 {
10984 do_drawbitmapexr(bmp, sdci, xoffset, yoffset);
10985 }
10986 break;
10987
10988 case DRAWLAYERR:
10989 {
10990 4327380 do_drawlayerr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp);
10991 }
10992 4327380 break;
10993
10994 case DRAWSCREENR:
10995 {
10996 do_drawscreenr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp);
10997 }
10998 break;
10999
11000 7818 case BMPRECTR: bmp_do_rectr(bmp, sdci, xoffset, yoffset); break;
11001 case BMPFRAMER: bmp_do_framer(bmp, sdci, xoffset, yoffset); break;
11002 1480 case BMPCIRCLER: bmp_do_circler(bmp, sdci, xoffset, yoffset); break;
11003 case BMPARCR: bmp_do_arcr(bmp, sdci, xoffset, yoffset); break;
11004 502 case BMPELLIPSER: bmp_do_ellipser(bmp, sdci, xoffset, yoffset); break;
11005 144 case BMPLINER: bmp_do_liner(bmp, sdci, xoffset, yoffset); break;
11006 case BMPSPLINER: bmp_do_spliner(bmp, sdci, xoffset, yoffset); break;
11007 80910 case BMPPUTPIXELR: bmp_do_putpixelr(bmp, sdci, xoffset, yoffset); break;
11008 59428 case BMPDRAWTILER: bmp_do_drawtiler(bmp, sdci, xoffset, yoffset); break;
11009 case BMPDRAWTILECLOAKEDR: bmp_do_drawtilecloakedr(bmp, sdci, xoffset, yoffset); break;
11010 824 case BMPDRAWCOMBOR: bmp_do_drawcombor(bmp, sdci, xoffset, yoffset); break;
11011 case BMPDRAWCOMBOCLOAKEDR: bmp_do_drawcombocloakedr(bmp, sdci, xoffset, yoffset); break;
11012 167316 case BMPFASTTILER: bmp_do_fasttiler(bmp, sdci, xoffset, yoffset); break;
11013 784 case BMPFASTCOMBOR: bmp_do_fastcombor(bmp, sdci, xoffset, yoffset); break;
11014 case BMPDRAWCHARR: bmp_do_drawcharr(bmp, sdci, xoffset, yoffset); break;
11015 case BMPDRAWINTR: bmp_do_drawintr(bmp, sdci, xoffset, yoffset); break;
11016 case BMPDRAWSTRINGR: bmp_do_drawstringr(bmp, i, sdci, xoffset, yoffset); break;
11017 45504 case BMPDRAWSTRINGR2: bmp_do_drawstringr2(bmp, i, sdci, xoffset, yoffset); break;
11018 case BMPQUADR: bmp_do_drawquadr(bmp, sdci, xoffset, yoffset); break;
11019 case BMPQUAD3DR: bmp_do_drawquad3dr(bmp, i, sdci, xoffset, yoffset); break;
11020
11021 case BITMAPGETPIXEL: bmp_do_getpixelr(bmp, sdci, xoffset, yoffset); break;
11022 case BMPTRIANGLER: bmp_do_drawtriangler(bmp, sdci, xoffset, yoffset); break;
11023 case BMPTRIANGLE3DR: bmp_do_drawtriangle3dr(bmp, i, sdci, xoffset, yoffset); break;
11024 case BMPPOLYGONR: bmp_do_polygonr(bmp, i, sdci, xoffset, yoffset); break;
11025 1173 case BMPDRAWLAYERR: do_bmpdrawlayerr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
11026 1092 case BMPDRAWSCREENR: do_bmpdrawscreenr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
11027 case BMPDRAWSCREENSOLIDR: do_bmpdrawscreen_solidmaskr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
11028 case BMPDRAWSCREENSOLID2R: do_bmpdrawscreen_solidr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
11029 1024 case BMPDRAWSCREENCOMBOFR: do_bmpdrawscreen_cflagr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
11030 case BMPDRAWSCREENCOMBOIR: do_bmpdrawscreen_ciflagr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
11031 case BMPDRAWSCREENCOMBOTR: do_bmpdrawscreen_ctyper(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
11032 236166 case BMPBLIT: bmp_do_drawbitmapexr(bmp, sdci, xoffset, yoffset); break;
11033 case BMPMODE7: bmp_do_mode7r(bmp, sdci, xoffset, yoffset); break;
11034 909 case BMPBLITTO: bmp_do_blittor(bmp, sdci, xoffset, yoffset); break;
11035 case READBITMAP: bmp_do_readr(bmp, i, sdci, xoffset, yoffset); break;
11036 case WRITEBITMAP: bmp_do_writer(bmp, i, sdci, xoffset, yoffset); break;
11037 26369 case CLEARBITMAP: bmp_do_clearr(bmp, sdci, xoffset, yoffset); break;
11038 2790 case BITMAPCLEARTOCOLOR: bmp_do_clearcolorr(bmp, sdci, xoffset, yoffset); break;
11039 34653 case REGENERATEBITMAP: bmp_do_regenr(bmp, sdci, xoffset, yoffset); break;
11040
11041 case BMPDRAWLAYERSOLIDR: do_bmpdrawlayersolidmaskr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
11042 case BMPDRAWLAYERCFLAGR: do_bmpdrawlayercflagr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
11043 case BMPDRAWLAYERCTYPER: do_bmpdrawlayerctyper(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
11044 case BMPDRAWLAYERCIFLAGR: do_bmpdrawlayerciflagr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
11045 case BMPDRAWLAYERSOLIDITYR: do_bmpdrawlayersolidityr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
11046 case BMPWRITETILE: do_bmpwritetile(bmp, sdci, xoffset, yoffset); break;
11047 case BMPDITHER: do_bmpdither(bmp, sdci, xoffset, yoffset); break;
11048 6363 case BMPREPLCOLOR: do_bmpreplcol(bmp, sdci, xoffset, yoffset); break;
11049 case BMPSHIFTCOLOR: do_bmpshiftcol(bmp, sdci, xoffset, yoffset); break;
11050 906 case BMPMASKDRAW: do_bmpmaskdraw(bmp, sdci, xoffset, yoffset); break;
11051 case BMPMASKBLIT: do_bmpmaskblit(bmp, sdci, xoffset, yoffset); break;
11052 }
11053 21230244 }
11054
11055
11056 44650310 color_map=&trans_table;
11057 44650310 }
11058
11059 5763274 void CScriptDrawingCommands::Clear()
11060 {
11061 5763274 scb.update();
11062
2/2
✓ Branch 0 taken 3605383 times.
✓ Branch 1 taken 2157891 times.
5763274 if(commands.empty())
11063 3605383 return;
11064
11065 //only clear what was used.
11066 2157891 memset((void*)&commands[0], 0, count * sizeof(CScriptDrawingCommandVars));
11067 2157891 count = 0;
11068
11069 2157891 draw_container.Clear();
11070 5763274 }
11071 CScriptDrawingCommands* CScriptDrawingCommands::pop_commands()
11072 {
11073 CScriptDrawingCommands* ret = new CScriptDrawingCommands();
11074 if(commands.empty())
11075 return ret;
11076 ret->push_commands(this, false);
11077
11078 memset((void*)&commands[0], 0, count * sizeof(CScriptDrawingCommandVars));
11079 count = 0;
11080
11081 draw_container.Clear();
11082 return ret;
11083 }
11084 void CScriptDrawingCommands::push_commands(CScriptDrawingCommands* other, bool del)
11085 {
11086 commands.insert(commands.end(), other->commands.begin(), other->commands.end());
11087 count += other->count;
11088 if(del) delete other;
11089 }
11090
11091 9181 void do_script_draws(BITMAP *targetBitmap, mapscr* theScreen, int32_t xoff, int32_t yoff, bool hideLayer7)
11092 {
11093
1/2
✓ Branch 0 taken 9181 times.
✗ Branch 1 not taken.
9181 if(XOR(theScreen->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(targetBitmap, 2, theScreen, xoff, yoff);
11094
2/2
✓ Branch 0 taken 8926 times.
✓ Branch 1 taken 255 times.
9181 if(XOR(theScreen->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(targetBitmap, 3, theScreen, xoff, yoff);
11095 9181 do_primitives(targetBitmap, 0, theScreen, xoff, yoff);
11096 9181 do_primitives(targetBitmap, 1, theScreen, xoff, yoff);
11097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9181 times.
9181 if(!XOR(theScreen->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(targetBitmap, 2, theScreen, xoff, yoff);
11098
2/2
✓ Branch 0 taken 255 times.
✓ Branch 1 taken 8926 times.
9181 if(!XOR(theScreen->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(targetBitmap, 3, theScreen, xoff, yoff);
11099 9181 do_primitives(targetBitmap, 4, theScreen, xoff, yoff);
11100 9181 do_primitives(targetBitmap, 5, theScreen, xoff, yoff);
11101 9181 do_primitives(targetBitmap, 6, theScreen, xoff, yoff);
11102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9181 times.
9181 if(!hideLayer7) do_primitives(targetBitmap, 7, theScreen, xoff, yoff);
11103 9181 }
11104